# Difference of Means Test 2 samples

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?

1 5 195.3 153.1 51.4
1 5 194.3 167.7 53.7
2 5 189.7 139.5 55.5
2 5 180.4 121.1 44.4
1 6 203.0 156.8 49.8
1 6 195.9 166.0 45.8
2 6 202.7 166.1 60.4
2 6 197.6 161.8 54.1
1 8 193.5 164.5 57.8
1 8 187.0 165.1 58.6
2 8 201.5 166.8 65.0
2 8 200.0 173.8 67.2

Any advice on how to run a T test for differences in means against all 4 columns?

Thank you in advance.

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
``````

Created on 2021-02-21 by the reprex package (v0.3.0)

Thank you for the reply, let's just say it would be the 1st column, against columns 3, 4 and 5 difference in means.

Is there a simple line of code that I can do that but just listing say column 1 against columns 3, 4 and 5?

Thanks again.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.