> sleep > sleep_wide <- data.frame( ID=1:10, group1=sleep$extra[1:10], group2=sleep$extra[11:20] ) > head(sleep) extra group ID 1 0.7 1 1 2 -1.6 1 2 3 -0.2 1 3 4 -1.2 1 4 5 -0.1 1 5 6 3.4 1 6 > head(sleep_wide) ID group1 group2 1 1 0.7 1.9 2 2 -1.6 0.8 3 3 -0.2 1.1 4 4 -1.2 0.1 5 5 -0.1 -0.1 6 6 3.4 4.4 > t.test(extra ~ group, sleep) Welch Two Sample t-test data: extra by group t = -1.8608, df = 17.776, p-value = 0.07939 alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0 95 percent confidence interval: -3.3654832 0.2054832 sample estimates: mean in group 1 mean in group 2 0.75 2.33 > t.test(extra ~ group, sleep, var.equal=TRUE) Two Sample t-test data: extra by group t = -1.8608, df = 18, p-value = 0.07919 alternative hypothesis: true difference in means between group 1 and group 2 is not equal to 0 95 percent confidence interval: -3.363874 0.203874 sample estimates: mean in group 1 mean in group 2 0.75 2.33 > t.test(sleep_wide$group1, sleep_wide$group2) Welch Two Sample t-test data: sleep_wide$group1 and sleep_wide$group2 t = -1.8608, df = 17.776, p-value = 0.07939 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -3.3654832 0.2054832 sample estimates: mean of x mean of y 0.75 2.33 > t.test(extra ~ group, sleep, paired=TRUE) Paired t-test data: extra by group t = -4.0621, df = 9, p-value = 0.002833 alternative hypothesis: true mean difference is not equal to 0 95 percent confidence interval: -2.4598858 -0.7001142 sample estimates: mean difference -1.58 > t.test(sleep$extra, mu=0) One Sample t-test data: sleep$extra t = 3.413, df = 19, p-value = 0.002918 alternative hypothesis: true mean is not equal to 0 95 percent confidence interval: 0.5955845 2.4844155 sample estimates: mean of x 1.54