Global growth: How much slower without China? (rCharts post)

 •  Filed under Data science and visualization, Own charts, China

A simple growth chart coded with rCharts

This interactive chart can be produced with just a few lines of code:

## Download global growth rates
csv  <- url("https://raw.github.com/zilinskyjan/datasets/master/fiscal/fiscal_global.csv")  
glob <- read.csv(csv)

## To run the mPlot command, load rCharts
library(rCharts)

## Treat years as characters to avoid display of days
glob$year <- as.character(glob$year)

## Make the chart
m2 <- mPlot(x = "year", y = c("gr_w", "gr_noChina"), type = "Line", data = glob)  
m2$set(pointSize = 0, lineWidth = 1)  
m2$print("globalGrowth")  

When copying the printed code, adjust labels as needed:

"pointSize":              0,
"lineWidth":              1,
"id": "globalGrowth",
"labels": ["Global growht", "Excluding China"] 

Add morris.js and the required dependencies to your html file:

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">  
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>  
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>  
<script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>