Skip to contents

run t test

Usage

ttest(
  x,
  y = NULL,
  alternative = "two.sided",
  mu = 0,
  paired = FALSE,
  var.equal = FALSE,
  conf.level = 0.95,
  ...
)

Arguments

x

a (non-empty) numeric vector of data values.

y

an optional (non-empty) numeric vector of data values.

Value

A list with class "htest" containing the following components:

Details

alternative = "greater" is the alternative that x has a larger mean than y. For the one-sample case: that the mean is positive. If paired is TRUE then both x and y must be specified and they must be the same length. Missing values are silently removed (in pairs if paired is TRUE). If var.equal is TRUE then the pooled estimate of the variance is used. By default, if var.equal is FALSE then the variance is estimated separately for both groups and the Welch modification to the degrees of freedom is used. If the input data are effectively constant (compared to the larger of the two means) an error is generated.

Examples

t.test(1:10, y = c(7:20))      # P = .00001855
#> 
#> 	Welch Two Sample t-test
#> 
#> data:  1:10 and c(7:20)
#> t = -5.4349, df = 21.982, p-value = 1.855e-05
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#>  -11.052802  -4.947198
#> sample estimates:
#> mean of x mean of y 
#>       5.5      13.5 
#>