t.test(introq$Ideal ~ introq$Gender)
Welch Two Sample t-test
data: Ideal by Gender
t = 17.218, df = 305.4, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
4.282968 5.388255
sample estimates:
mean in group 1 mean in group 2
71.43006 66.59444
It would be easier to deal with the output if I did not need to remember which numeric code
stands for male and which for female. Fortunately, SPSS will, upon request, write value labels to the
csv file, so I went back to SPSS and exported to csv with that request.
Gender Ideal Eye Statoph Nucoph SATM Year
1 Female 68.0 Other 8.0 50 NA 2105
2 Male 64.0 Other 4.0 40 NA 2105
3 Male 68.0 Other 5.0 30 430 2105
4 Female 72.0 Green 10.0 100 540 2105
As you can see, above, the csv file now has value labels, rather than numeric values, for the
categorical variables. When I read in the new csv file and run the t test again, I get
Welch Two Sample t-test
data: Ideal by Gender
t = 17.218, df = 305.4, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
4.282968 5.388255
sample estimates:
mean in group Female mean in group Male
71.43006 66.59444
Notice that, by default, R does a separate variances t test. This is, IMHO, a good idea, but if
you want a pooled variances t test, you can get it this way. Even though the sample sizes here differ
quite a bit, the sample variances are nearly identical, so I am comfortable with the pooled test.
t.test(introq$Ideal ~ introq$Gender, var.equal=TRUE)
Two Sample t-test
data: Ideal by Gender
t = 17.274, df = 717, p-value < 2.2e-16
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
4.286033 5.385189
sample estimates:
mean in group Female mean in group Male
71.43006 66.59444