Web EndMemo

R t test


t.test(...) function returns a t test result of two group data sets. It's expression is:

t.test(x, y = NULL,
       alternative = c("two.sided", "less", "greater"),
       mu = 0, paired = FALSE, var.equal = FALSE,
       conf.level = 0.95, ...)

x,y:Numeric vectors
alternative:Alternativ Hypothesis
mu:True value of the mean
paired:Paired t-test or not
...
Suppose we have two dataset, let's do a t test
>x <- c(1.2,3.4,1.3,-2.1,5.6,2.3,3.2,2.4,2.1,1.8,1.7,2.2)
>y <- c(2.4,5.7,2.0,-3,13,5,6.2,4.8,4.2,3.5,3.7,5.2)
>ret <- t.test(x,y)
>ret

        Welch Two Sample t-test

data:  x and y 
t = -1.9667, df = 15.943, p-value = 0.06688
alternative hypothesis: true difference in means is not equal to 0 
95 percent confidence interval:
 -4.7799367  0.1799367 
sample estimates:
mean of x mean of y 
 2.091667  4.391667