I have a question, I need to do a t-test of one column, against 4 other columns in a data set. The value of the first column is 1 or 2, the values of all of the other columns vary. Thank you in advance by the way.
How do I do a difference of means test on something like this?
Do you meant that within each of columns 2 - 5 you want to test whether the values with 1 in the first column have a different mean than those with 2 in the first column? You could do that with code like the following, though the example just tests one column.
You should check that the assumptions of a t test are appropriate for your data. In particular, the second column with small integer values may not be normally distributed around the means.
#invent data
set.seed(1)
DF <- data.frame(Group = rep(c(1,2), each = 25),
Value = c(rnorm(25, 1,0.5), rnorm(25, 1.5, 0.5)))
t.test(Value ~ Group, data = DF)
#>
#> Welch Two Sample t-test
#>
#> data: Value by Group
#> t = -3.6472, df = 44.32, p-value = 0.000694
#> alternative hypothesis: true difference in means is not equal to 0
#> 95 percent confidence interval:
#> -0.6703269 -0.1932393
#> sample estimates:
#> mean in group 1 mean in group 2
#> 1.084333 1.516116