##
## plot Expenses as a percent of the
## federal budget and of GDP
##
data(USPS)
plot(Expenses_pFed~Year, USPS, type='l')
plot(Expenses_pGDP~Year, USPS, type='l')
plot(100*periodicals/piecesOfMail~Year,
USPS, type='l', ylab='',
main='periodicals as percent of mail')
# Select a year
# as a charcter string not a number:
USPS['1850',]
##
## Plot Expenses_pGDP with
## USGDPpresidents[, 'fedOutlays_pGDP']
##
str(yrs2 <- intersect(USPS$Year,
USGDPpresidents$Year))
yrs2a <- as.character(yrs2)
str(USPS_fed <- cbind(USPS[yrs2a, "Expenses_pGDP"],
USGDPpresidents[yrs2a, "fedOutlays_pGDP"]))
matplot(yrs2, USPS_fed, log='y',
ylab='', las=1, type='l', xlab='')
abline(v=c(1840, 1844), lty='dotted', col='grey')
text(1842, 6e-3, cex=.7,
'McChesney & Nichols analysis', srt=90, col='grey')
abline(v=c(1861, 1865), lty='dotted', col='grey')
text(1863, 6e-3, 'Civil War', srt=90, col='grey')
sel1 <- (USGDPpresidents$war=='World War I')
(yr1 <- USGDPpresidents$Year[sel1])
abline(v=yr1, col='grey', lty='dotted')
text(mean(yr1), 2e-3, 'WWI', col='grey', srt=90)
sel2 <- (USGDPpresidents$war=='World War II')
(yr2 <- range(USGDPpresidents$Year[sel2]))
abline(v=yr2, col='grey', lty='dotted')
text(mean(yr2), 2e-3, 'WWII', col='grey', srt=90)
abline(h=c(.001, .01, .1), lty='dotted', col='grey')
legend("bottomright",
c('USPS Expenses_pGDP', 'fedOutlays_pGDP'),
col=1:2, lty=1:2, bty='n')
Run the code above in your browser using DataLab