Skip to content

Instantly share code, notes, and snippets.

@msund
Last active August 29, 2015 14:03
Show Gist options
  • Save msund/a10c79fe88bb9ab89541 to your computer and use it in GitHub Desktop.
Save msund/a10c79fe88bb9ab89541 to your computer and use it in GitHub Desktop.
install.packages("devtools") # windows users install Rtools. Also: for mac and linux.
library("devtools")
install_github("ropensci/plotly") # Plotly is part of the super cool rOpenSci.
library(plotly) # install libraries we’ll be using
library(ggplot2)
library(reshape)
py <- plotly("ggplot2examples", "3gazttckd7") # sign up (https://plot.ly/ssi/) and get a key or use our public key to initiate a graph object
library(WDI) # now we’ll make the plot from the blog post
library(ggplot2)
dat = WDI(indicator='NY.GNP.PCAP.CD', country=c('CL','HU','UY'), start=1960, end=2012) # Grab GNI per capita data for Chile, Hungary and Uruguay
wb <- ggplot(dat, aes(year, NY.GNP.PCAP.CD, color=country)) + geom_line()
+ xlab('Year') + ylab('GDI per capita (Atlas Method USD)')
+ labs(title <- "GNI Per Capita ($USD Atlas Method)")
py$ggplotly(wb) # call Plotly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment