For this worksheet we will use an extended version of the inaugural dataset in which I have added a column for "we". It is available here (with whitespace-separated columns, in case you want to use read.csv() to read it in rather than the GUI).
Below, I assume that you have read it in as a data frame called "inaugural". (Rename it from "inauguralX" to "inaugural".)
If you want a plot for official purposes like a research paper, you need to have proper labels on the x and y axes, and ideally also a label for the whole graph. Here is an example, plotting counts of "freedom" versus "duties" with the year on the x axis, and with x and y labels:
Also, you need a legend that states what each line represents:
This command places a legend at x value 1800 and y value 25, showing the words "freedom" and "duties" with a box (point character "pch" 15) next to each of them, The boxes are to be red and blue, respectively. The text size, "cex", is reduced to 80% of normal.
You can look up graphing parameters by typing "?par". The point characters are explained under the entry of "points", so look them up using "?points"
The graphs as we had them up to now are not friendly to colorblind people, who may not see the difference between the red and the blue lines. Here are some options:
The R command text() plots texts at the given x and y coordinates. This can sometimes be a fun visualization option.
To plot how many counts of "freedom" versus "duties" each (recent) president has, we can use the count of freedom as the x axis and the count of duties as the y axis, and plot each president name at the matching coordinates. We only use speeches more recent than 1960, otherwise the plot gets too busy.
This makes a data frame inaug.new of recent speeches. It then plots nothing -- that is what type = "n" does. The plot command just sets up the canvas to have the right size (so it fits all counts of freedom on the x axis, and all counts of duties on the y axis), and labels the axes. We need to do that because "text" does not start a new canvas, it superimposes on the previous one.
The third command, "text", then prints each president's name at the matching coordinates. For example, Obama is at coordinates (3,2) because his speech contains "freedom" three times and "duties" twice.