Skip to content

Instantly share code, notes, and snippets.

@creative-quant
Created March 8, 2016 19:23
Show Gist options
  • Save creative-quant/020e0b69820baa9d5f0c to your computer and use it in GitHub Desktop.
Save creative-quant/020e0b69820baa9d5f0c to your computer and use it in GitHub Desktop.
library(xts)
library(ggplot2)
#cad gdp
#curl http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/03790031-eng.zip -o /tmp/ca.gpd.zip && unzip /tmp/ca.gpd.zip -d /tmp
#curl http://www.statcan.gc.ca/cgi-bin/sum-som/fl/cstsaveascsv.cgi?filename=gdps04a-eng.htm&lan=eng -o
#http://www20.statcan.gc.ca/tables-tableaux/cansim/csv/03790031-eng.zip
#Ref_Date,GEO,SEAS,PRICES,NAICS,Vector,Coordinate,Value
if( !exists( "ca.gdp" ) ) {
ca.gdp <- read.csv("/tmp/03790031-eng.csv")
}
ca.gdp.byVector <-ca.gdp[ which( ca.gdp$Vector == "v65201210" ), ]
ca.gdp.byVector$Ref_Date <- as.Date(as.yearmon( ca.gdp.byVector$Ref_Date, "%Y/%m" ))
df <- data.frame( date=ca.gdp.byVector$Ref_Date, gdp=ca.gdp.byVector$Value )
plot <- ggplot( df, aes(x=date, y=as.double(gdp)) ) +
geom_line( colour="red" )
plot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment