Skip to content

Instantly share code, notes, and snippets.

@creative-quant
Created January 26, 2016 00:54
Show Gist options
  • Save creative-quant/3eb60f5300ef17e24183 to your computer and use it in GitHub Desktop.
Save creative-quant/3eb60f5300ef17e24183 to your computer and use it in GitHub Desktop.
CAD CPI plot
#$ curl -o /tmp/cad.cpi.csv http://www.statcan.gc.ca/daily-quotidien/160122/cg160122a001-eng.csv
# "The 12-month change in the Consumer Price Index (CPI) and the CPI excluding gasoline, 12-month % change"
# ,"CPI","CPI excluding gasoline"
library(ggplot2)
cad.cpi <- read.table( "/tmp/cad.cpi.csv", sep = ",", col.names=c("date", "cpi", "exgas"), skip=2, fill=T )
cad.cpi <- cad.cpi[1:(nrow( cad.cpi ) - 1),]
cad.cpi$date = as.Date( paste( cad.cpi$date, '01' ), "%B %Y %d" )
df <- data.frame(cad.cpi)
plot <- ggplot( df, aes(x=date, y=cpi) ) +
geom_line( colour="red" ) +
geom_line( aes( y=exgas ) )
plot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment