Learn R Programming

broom (version 0.3.4)

htest_tidiers: Tidying methods for an htest object

Description

Tidies hypothesis test objects, such as those from cor.test, t.test, and wilcox.test, into a one-row data frame.

Usage

## S3 method for class 'htest':
tidy(x, ...)

## S3 method for class 'htest': glance(x, ...)

Arguments

x
An object of class "htest"
...
extra arguments (not used)

Value

  • Both tidy and glance return the same output, a one-row data frame with one or more of the following columns:
  • estimateEstimate of the effect size
  • statisticTest statistic used to compute the p-value
  • p.valueP-value
  • parameterParameter field in the htest, typically degrees of freedom
  • conf.lowLower bound on a confidence interval
  • conf.highUpper bound on a confidence interval
  • estimate1Sometimes two estimates are computed, such as in a two-sample t-test
  • estimate2Sometimes two estimates are computed, such as in a two-sample t-test
  • Which columns are included depends on the hypothesis test used.

Details

No augment method is provided for "htest", since there is no sense in which a hypothesis test generates one value for each observation.

Examples

Run this code
tt <- t.test(rnorm(10))
tidy(tt)
glance(tt)  # same output for all htests

tt <- t.test(mpg ~ am, data = mtcars)
tidy(tt)

wt <- wilcox.test(mpg ~ am, data = mtcars)
tidy(wt)

ct <- cor.test(mtcars$wt, mtcars$mpg)
tidy(ct)

Run the code above in your browser using DataLab