# GDP under American presidents by party # (elementary R example) # # Chris Adolph, cadolph@uw.edu # March 27, 2012 # Clear memory rm(list=ls()) # Load data data <- read.csv("gdp.csv",na.strings="") attach(data) # Construct party specific variables gdp.dem <- grgdpch[party==-1] gdp.rep <- grgdpch[party==1] # Make the histogram hist(grgdpch, breaks=seq(-5,8,1), main="Histogram of US GDP Growth, 1951--2000", xlab="GDP Growth") # Make a box plot boxplot(grgdpch~as.factor(party), boxwex=0.3, range=0.5, names=c("Democratic\n Presidents", "Republican\n Presidents"), ylab="GDP growth", main="Economic performance of partisan governments")