# Data from W.S. Gosset's 1908 paper on the t-test. # Two different sleeping drugs were taken by two groups of patients. # The variable "extra" is the increase in hours of sleep on the groups # (consisting of 10 patients each). # The variable "group" gives the labels for which drug each patient took. # The sleeping data is a built-in data set in R, # so we can simply load it and attach it with the following: data(sleep); attach(sleep) # Viewing the data: print(extra) print(group) # Alternately, we could type in the variables in the usual way: #extra <- c(0.7,-1.6,-0.2,-1.2,-0.1,3.4,3.7,0.8, #0.0,2.0,1.9,0.8,1.1,0.1,-0.1,4.4,5.5,1.6,4.6,3.4) #group <- c(1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2) boxplot(extra ~ group) # Do the spreads seem equal across groups? # Assuming equal variances: t.test(extra ~ group, var.equal=TRUE) # Not assuming equal variances: t.test(extra ~ group)