Mean absolute distance to mean: (not usually used)
The second line finds in this new data frame freq.df all the lines in which the Freq value is the same as the maximum Freq value, and displays their inaugural.freedom value: Which are all the inaugural.freedom values that are maximally frequent? So it displays multiple modes if there is more than one.
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.
If you just ask for the quantiles without further parameters, you get the lowest, the 1st quartile, the median, the 3rd quartile, and the highest:
If you feel like it, you can also request deciles:
Mode: This is not a one-liner 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).
The first line creates a data frame that counts how often each count of "freedom" occurs. Its columns are "inaugural.freedom" and "Freq". Visualize this data frame by itself. (It takes the output of xtabs and transforms it to a data frame.)
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.
The dative dataset is available in the package languageR. Once you have installed the package, you make it available using
The dative dataset is the extended version of the verbs dataset. Get an idea of what it contains using
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: