published by adam on Mon, 05/28/2012 - 17:45
If you use R for time series analysis, chances are you've used Robert J. Hyndman's excellent forecast tools. I recently stumbled on his time series data library where I found just the data set I've been looking for to show some R time series plotting tricks:
http://robjhyndman.com/tsdldata/roberts/beards.dat
It's the percentage of American men with full beards reported annually. Nothing serious here, but absurdly perfect for a set of posts to share a couple things that took me a while to learn when plotting in R.
What you'll learn
-
How to grab data from a plaintext source on the web, stripping header information
-
How to convert a list of data with a known start time and end time into an xts time series object
-
How to convert xts to a data.frame for plotting in ggplot2
-
Aesthetics for red data points with dotted line interpolation
-
How much American beardfulness there was in the late 19th century and early 20th.