See stats::t.test for details.

# S3 method for default
t_test(
  x,
  y = NULL,
  alternative = c("two.sided", "less", "greater"),
  mu = 0,
  paired = FALSE,
  var.equal = FALSE,
  conf.level = 0.95,
  names = NULL,
  ...
)

Arguments

x

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

y

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

alternative

a character string specifying the alternative hypothesis, must be one of "two.sided" (default), "greater" or "less". You can specify just the initial letter.

mu

a number indicating the true value of the mean (or difference in means if you are performing a two sample test).

paired

a logical indicating whether you want a paired t-test.

var.equal

a logical variable indicating whether to treat the two variances as being equal. If TRUE then the pooled variance is used to estimate the variance otherwise the Welch (or Satterthwaite) approximation to the degrees of freedom is used.

conf.level

confidence level of the interval.

names

optional group names for 2-sample tests

...

further arguments to be passed to or from methods.

Examples

t_test(rnorm(20), rnorm(20, 0.25), names = c("A", "B"))$n
#>  A  B 
#> 20 20 

t_test(mtcars$mpg, mu = 20)$n
#> [1] 32

v <- rnorm(20)
v[3] <- NA
t_test(v)$n
#> [1] 19