pplot | R Documentation |
A paired plot for continuous data. Draws a dot plot with points jittered
to the left and right about the group position. Jittering is done with
beeswarm
; however, the original data values are
used instead of using the slight adjustments made by beeswarm
.
Additionally, a two-sample wilcox.test
test is performed
on each pair by default, but the test and assumptions may be controlled
using test
and args.test
arguments, respectively; see
examples.
pplot(x, ...)
## S3 method for class 'formula'
pplot(formula, data, ...)
## Default S3 method:
pplot(
x,
at = seq_along(x),
pad = 0.05,
test = wilcox.test,
args.test = list(),
col = 1:2,
pch = par("pch"),
cex = par("cex"),
args.beeswarm = list(),
names,
quantiles = NULL,
pch.quantiles = rep_len(16L, length(quantiles)),
xlab = NULL,
ylab = NULL,
legend.text = NULL,
...
)
x |
for the default method, a list of groups each having a list of length 2 of data values |
... |
for the for the default method, additional arguments passed to |
formula |
a |
data |
a data frame (or list) from which the variables in
|
at |
the x-axis group positions |
pad |
the padding between |
test |
logical or function; if alternatively, a function (or function name as a character string) can be
used, e.g., |
args.test |
a named list of arguments passed to |
col , pch , cex |
color, plotting character, and character expansion vectors, each may be length 1, 2, or total number of groups to be plotted, recycled as needed |
args.beeswarm |
a named list of arguments passed to
|
names |
group labels having the same length as |
quantiles |
optional probabilities passed to |
pch.quantiles |
plotting character for each quantile |
xlab , ylab |
x- and y-axis labels |
legend.text |
group labels of length 2 |
## basic usage
pplot(split(mtcars$mpg, mtcars$vs))
pplot(mpg ~ vs, mtcars)
set.seed(1)
x <- lapply(1:5, function(x) list(rnorm(20, 0, x), rnorm(20, 0, x)))
pplot(x)
pplot(x[1], ylim = c(-3, 3))
pplot(x, test = t.test, args.test = list(paired = TRUE))
pplot(x, col = rep(2:6, each = 2), pch = c(1, 16), legend.text = c('+', '-'))
pplot(x, quantiles = 0.5, legend.text = c('+', '-'))
## pplot returns the object returned by test
pv <- pplot(
x, quantiles = c(0.25, 0.5, 0.75), pch.quantiles = c(6, 18, 2),
legend.text = c('+', '-'), pad = 0.1, pch = 16, bty = 'l',
names = paste('group', 1:5), las = 1
)
sapply(pv, function(x) x$p.value)
## use a custom test function
pplot(x, test = function(x, y) cor.test(x, y, method = 'spearman'))
moods <- function(x, y) rawr::moods.test(list(x, y))
pplot(x, test = moods)
sapply(x, function(y) do.call('moods', y)$p.value)
## formula method
pplot(mpg ~ gear + am, mtcars)
pplot(mpg ~ gear + vs, mtcars, xlab = 'Gears', legend.text = c('V', 'S'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.