R Instructions: Using Technology with Data to Run a Hypothesis Test

To carry out the test, open R with the dataset preloaded by right-clicking here and choosing "Save Target As" to download the file to your computer. Then find the downloaded file and double-click it to open it in R.

The data have been loaded into the variable "sleep." Enter the command sleep to see the data.

To carry out the t-test, enter the command:

t.test(sleep$undergraduate,sleep$graduate,alternative = "less")

Note: Using R—when we used t.test for a one-sample t-test in a previous activity, we specified one sample dataset, a hypothetical mean, and an alternative hypothesis. To perform a two-sample t-test, we use the same command t.test but specify two sample datasets and an alternative hypothesis.