An R package to ease data visualization.
The aim of this package is to make visualization an early part of the data analysis process by automating a few common plotting tasks.
In terms of design, it has three general principles:
By entering a formula as the first argument in the splot
function (e.g., splot(y ~ x)
), you can make
by
variable)For each type, multiple y
variables or data at levels of
a by
variable are shown in the same plot frame,
and
data at levels of one or two between
variables are shown in
separate plot frames, organized in a grid.
Download R from r-project.org.
Release (version 0.5.4)
install.packages("splot")
Development (version 0.5.5)
# install.packages("remotes")
::install_github("miserman/splot") remotes
Then load the package:
library(splot)
Make some data: random group and x variables, and a y variable related to x:
= rep(c("group 1", "group 2"), 50)
group = rnorm(100)
x = x * .5 + rnorm(100) y
The distribution of y:
splot(y)
A scatter plot between y and x:
splot(y ~ x)
Same data with a quadratic model:
splot(y ~ x + x^2 + x^3)
Same data separated by group:
splot(y ~ x * group)
Could also separate by median or standard deviations of x:
splot(y ~ x * x)
splot(y ~ x * x, split = "sd")
Summarize with a bar plot:
splot(y ~ x * group, type = "bar")
Two-level y variable with a probability prediction line:
# make some new data for this example:
# a discrete y variable and related x variable:
= rep(c(1, 5), 50)
y_bin = y_bin * .4 + rnorm(100)
x_con
# lines = "prob" for a prediction line from a logistic model:
splot(y_bin ~ x_con, lines = "prob")