The Project

We want to compare the performance of the US presidents beginning with Ronald Reagan and ending with Barack Obama using actual economic data from official sources. We will use data from the Federal Reserve Economic Data (FRED) system.

The main FRED page is at

There are five variables from FRED to be used in our analysis. Each of these can be thought of as a performance measure in the area of macroeconomics.

The variables in the form we want to use them are all in the CSV file indicators.csv.

Task 1: Import the Data.

Most of this is easy, but handling the date raises a question. Before doing the import, google for “r data format.” Examine the data with the usual tools after you import it.

Task 2: Visualization Strategy

How do we want to visualize this data? Can we work with the data as is, or do we need to restructure it?

Produce a time-series graph of one performance measure for one president.

Task 3: A First Try at Comparison.

Produce a time series plot of the data for each variable. Map the presidents’ names to color.

Task 4: Restructure the Data

We need to create a narrow version of our dataframe in which the indicator names are the contents of a variable rather than variable names. The name of the variable will be “indicator” and the values will be in a variable called “value.” Call the resulting dataframe “indg.”

Task 5: First Facetting Attempt

Create a basic scatterplot of value against time. Use facet_grid() to put indicators in rows and presidents’ names in column.

What Problems do we see in this graph?

Task 6: Fix the Scales;

Note that every cell in the grid has the same scale. The value and date axes are all able to accomodate every possible value. Fix this.

Task 7: Make Presidents a Factor.

The next problem is that the names of the presidents are in alphabetical order. Use the levels argument of factor() to put the presidents’ names in chronological order.

Task 8: Fix Indicator Names.

The names of the indicator variables are somewhat cyrptic. These should be replace with reader-friendly labels. Use the labels argument of the factor function to make these. Remember that the order of levels is established by the sorting order of the original values. This order must be followed in assigning labels.

Task 9: Make Labels Horizontal

The indicator labels are easier to understand, but still hard to read. Investigate the use of Theme() options to change the angle of the y-axis strip text.

Task 10: Make it Colorful

Enhance the appearance of the graph by mapping col to the name of the president. The default colors are a bit wimpy, so pick something better using scale_color_brewer.

Task 11: Eliminate the Legend

Investigate the Theme() options for dealing with the legend.

Task 12: Add a Smoother

Play with the parameters to get something you like. Also change the angle of the years on the x-axis to avoid the overprinting. Finally save the result to both a pdf file and a jpg file.