1. library(WDI)
  2. top10 = c('US', 'CN', 'JP', 'DE', 'FR', 'GB', 'BR', 'RU', 'IT', 'IN')
  3. gdp = WDI(top10, indicator = "NY.GDP.MKTP.CD", start = 1980, end = 2012)
  4. gdp = transform(gdp, NY.GDP.MKTP.CD = NY.GDP.MKTP.CD/10^9)
  5. library(rCharts)
  6. n1 <- nPlot(NY.GDP.MKTP.CD ~ year, data = gdp, group = 'country',
  7. type = 'stackedAreaChart', width = 800, height = 400
  8. )
  9. n1$yAxis(
  10. axisLabel = 'Billions of Dollars',
  11. tickFormat = "#! d3.format('0.0f') !#"
  12. )
  13. n1