Performing t Tests
We use t tests to compare means. You have already seen that the t.test function can be used to display confidence intervals for means and differences between means. The t.test function in R is used for all three kinds of t tests: one-sample, paired-samples, and two-sample t tests.
In general, we calculate a mean difference and divide that by the standard error of the mean difference. Although we can conceivably perform one-sample, paired-samples, and two-sample z tests, and these are taught in some statistics classes and texts, for the reasons we have discussed repeatedly, the t tests work better than the z tests ...