mosaic (version 0.14.4)

t_test: Student's t-Test

Description

Performs one and two sample t-tests. The mosaic t.test provides wrapper functions around the function of the same name in stats. These wrappers provide an extended interface that allows for a more systematic use of the formula interface.

Usage

t_test(x, y = NULL, ..., data = parent.frame())

t.test(x, y=NULL, ..., data = parent.frame())

Arguments

x

a formula or a non-empty numeric vector

y

an optional non-empty numeric vector or formula

data

a data frame

additional arguments, see t.test in the stats package. When x is a formula, groups can be used to compare groups: x = ~ var, groups=g is equivalent to x = var ~ g . See the examples.

Value

an object of class htest

Details

This is a wrapper around t.test from the stats package to extend the functionality of the formula interface. In particular, one can now use the formula interface for a 1-sample t-test. Before, the formula interface was only permitted for a 2-sample test. The type of formala that can be used for the 2-sample test has also be broadened. See the examples.

See Also

prop.test, binom.test, t.test

Examples

Run this code
# NOT RUN {
if (require(mosaicData)) {
  t.test(~ age, data=HELPrct)
  t.test(age ~ sex, data=HELPrct)
  t.test(~ age | sex, data=HELPrct)
  t.test(~ age, groups=sex, data=HELPrct)
}
# }

Run the code above in your browser using DataLab