In this worksheet, we use the data frame inauguralX (columns separated by whitespace). It is the same as inaugural, except that it has an extra column counting "we". We use it under the name "inaugural" below. Measuring central tendencyMean:mean(inaugural$length) # which is the same as: sum(inaugural$length) / length(inaugural$length) Median: median(inaugural$length) # which is the same as: quantile(inaugural$length, probs = 0.5) > quantile(inaugural$length) 0% 25% 50% 75% 100% 147.00 1544.00 2380.00 3172.25 9165.00 > quantile(inaugural$length, probs = c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1)) 0% 10% 20% 30% 40% 50% 60% 70% 80% 90% 147.0 1223.5 1478.0 1770.0 1935.0 2380.0 2585.0 2873.5 3693.0 4406.5 100% 9165.0 Mode: This is not a oneliner in R, but here is how you do it. We use the counts of "freedom", not the speech lengths, as the speech lengths never repeat, so there is no mode (or everything is a mode). freq.df = data.frame( xtabs( ~inaugural$freedom) ) freq.df[ which(freq.df$Freq == max(freq.df$Freq)), ]$inaugural.freedom SpreadRange:range(inaugural$length) mean(abs(inaugural$length  mean(inaugural$length))) Variance: var(inaugural$length) Standard deviation: sd(inaugural$length) # which is the same as: sqrt(var(inaugural$length)) Visualizationhist() and the command truehist() from the MASS package show histograms. Here are the histograms and a density plot: (The first line sets the canvas up for plotting three things at once in a row).par(mfrow = c(1,3)) hist(inaugural$length) library(MASS) truehist(inaugural$length) plot(density(inaugural$length)) boxplot() shows the first and third quartile as a box with the median as a line through the box. The whiskers extend 1.5 times the length of the box by default (though you can change that), and outliers further than that are shown as dots. Over to you
Problems using the dative datasetThe dative dataset is available in the package languageR. Once you have installed the package, you make it available using library(languageR) head(dative) The column RealizationOfRecipient is the outcome we are interested in: "NP" stands for the form "John gave Mary the book", and "PP" stands for "John gave the book to Mary". Using the dative dataset:

Courses > R worksheets >