Learn R Programming

mosaic (version 0.8-18)

compareMean: Compare means between 2 groups

Description

A function to calculate the difference between the means two of groups for a continuous outcome variable

Usage

compareMean(formula, data = NULL, ...)

Arguments

formula
a formula
data
a data frame in which x is evaluated if x is a formula.
...
other arguments

Value

  • the difference in means between the second and first group

See Also

do, compareProportion and shuffle

Examples

Run this code
data(HELPrct)
# calculate the observed difference
mean(age ~ sex, data=HELPrct)
obs <- compareMean(age ~ sex, data=HELPrct); obs
# calculate the permutation distribution
nulldist <- do(100) * compareMean(age ~ shuffle(sex),
  data=HELPrct)
histogram(~ result, groups=(result >= obs), nulldist,
  xlab="difference in means")

Run the code above in your browser using DataLab