stat_between_test: Between group test

View source: R/statistical.R

stat_between_testR Documentation

Between group test

Description

Function to calculate statistics and P-value for both parametric and nonparametric tests.

Usage

stat_between_test(
  data = NULL,
  x,
  y,
  type = c("nonparametric", "parametric"),
  ...
)

Arguments

data

a data.frame object containing the variables in the x and y or NULL.

x, y

if data supplied, x and y are quoted arguments, can be a list, if x or y is a list object, each element in x and in y will be paired to implement test; if data is NULL, x and y should be a vector or a list with atmomic vector in the same length.

type

if type = "nonparametric", wilcox.test or kruskal.test is used.
if type = "parametric", t.test or aov is used.
which method is used depends on the unique values of x in data

...

other arguments passed to statistical test function, wilcox.test, kruskal.test, t.test and aov

Details

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.

Value

a tibble of the test results where each row match each pair of x and y. (see tidy)

Quasiquotation

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.

Author(s)

Yun yunyunpp96@outlook.com

Examples

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"
)

Yunuuuu/yjtools documentation built on Jan. 29, 2024, 5:30 a.m.