stat_between_test | R Documentation |
Function to calculate statistics and P-value for both parametric and nonparametric tests.
stat_between_test(
data = NULL,
x,
y,
type = c("nonparametric", "parametric"),
...
)
data |
a data.frame object containing the variables in the x and y or NULL. |
x, y |
if |
type |
if |
... |
other arguments passed to statistical test function,
|
if type = "nonparametric"
, wilcox.test
or kruskal.test
is used.
if type =
"parametric"
, t.test
or aov
is
used.
The final choice of which method is used depends on the unique
values of x
term.
a tibble of the test results where each row match each pair of x and
y. (see tidy
)
if data
supplied, x
and y
in
stat_between_test()
are quoted
arguments
This means that its inputs are quoted to be evaluated in the
context of the data. This makes it easy to work with variables from the
data frame because you can name those directly. The flip side is that you
have to use quasiquotation
to program with
stat_between_test()
. See a tidy evaluation tutorial such as the
dplyr
programming vignette to learn more about these techniques.
stat_between_test(mtcars, factor(vs), mpg, type = "p")
stat_between_test(mtcars, factor(vs), mpg, type = "n")
stat_between_test(mtcars, factor(cyl), mpg, type = "p")
stat_between_test(mtcars, factor(cyl), mpg, type = "n")
stat_between_test(
x = lapply(mtcars[c(2, 8)], as.factor),
y = mtcars[c(1, 3, 4)], type = "n"
)
stat_between_test(
x = factor(mtcars[["vs"]]),
y = mtcars["mpg"], type = "n"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.