This document shows “How the ‘Manufacturing, value added (% of GDP)’ changed over time” using R(rCharts, dygraphs packages).
options(warn=-1)
suppressPackageStartupMessages(library(knitr))
suppressPackageStartupMessages(library(WDI))
suppressPackageStartupMessages(library(tidyr))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(xts))
suppressPackageStartupMessages(library(zoo))
suppressPackageStartupMessages(library(dygraphs))
suppressPackageStartupMessages(library(rCharts))
suppressPackageStartupMessages(library(pipeR))
opts_chunk$set(prompt=TRUE, warning=FALSE, error=FALSE, results = "asis", comment=NA, tidy=FALSE)
#Country code(ISO-2 character, G20 + my interests)
iso2c <- c("AU", "AT", "BE", "BR", "KH", "CA", "CN", "DK", "FI", "FR", "DE", "GR", "IN", "ID",
"IT", "JP", "KP", "KR", "MY", "MX", "NL", "NZ", "NO", "PH", "PT", "RU", "SA", "SG",
"ZA", "ES", "SE", "CH", "TH", "TR", "AE", "GB", "US", "VN")
#Get data
manu <- WDI(country=iso2c, indicator='NV.IND.MANF.ZS', start=1960, end=2013)
To visualize data with rCharts(nPlot, NVD3), You have to write as the folloing: (You have to be careful not to choose so much counties because it is too heavy to show)
> #rCharts(nPlot, NVD3)
> data_nplot <- manu %>>% na.omit %>>% select(-iso2c) %>>%
+ rename(value=NV.IND.MANF.ZS) %>>%
+ mutate(value=round(value)) %>>%
+ as.data.frame
> nplot <- nPlot(value~year, data=data_nplot, group="country", type="lineChart")
> #Default country : Japan
> nplot$set(disabled = unique(data_nplot$country) %>>% (.!="Japan"))
> nplot$yAxis(axisLabel="Manufacturing, value added (% of GDP)")
> nplot$xAxis(axisLabel="Year")
> nplot$set(height=550, width=850)
> nplot$show("iframesrc", cdn=TRUE)
In addition to that, I make a graph with dygraph package. It it a little bit difficult to understand at first sight :(
> #Make a color
> #Caution:We must seem to remove the last two characters(alpha value) and name attribution
> cl <- rainbow(length(iso2c)) %>% sapply(function(x)substr(x, 1, 7))
> names(cl) <- NULL
> #dygraph
> manu %>>% select(year, country, NV.IND.MANF.ZS) %>>% na.omit %>>%
+ spread(key=country, value=NV.IND.MANF.ZS) %>>%
+ as.data.frame %>>%
+ mutate(year=as.Date(as.character(year), "%Y")) %>>%
+ read.zoo %>>% as.xts %>>%
+ dygraph(main="USDJPY and EURJPY charts") %>>%
+ dyHighlight(hideOnMouseOut=FALSE, highlightSeriesOpts=list(strokeWidth = 3)) %>>%
+ dyLegend(show = "always", hideOnMouseOut=FALSE) %>>%
+ dyOptions(colors=cl)
To Search the indicator of WDI function, we can use
> #Search data key
> WDIsearch('manufacturing')
indicator
[1,] “EN.CO2.MANF.MT”
[2,] “EN.CO2.MANF.ZS”
[3,] “NV.IND.MANF.CD”
[4,] “NV.IND.MANF.CN”
[5,] “NV.IND.MANF.KD”
[6,] “NV.IND.MANF.KD.ZG”
[7,] “NV.IND.MANF.KN”
[8,] “NV.IND.MANF.KN.ZG”
[9,] “NV.IND.MANF.ZS”
[10,] “NV.MNF.CHEM.ZS.UN”
[11,] “NV.MNF.FBTO.ZS.UN”
[12,] “NV.MNF.MTRN.ZS.UN”
[13,] “NV.MNF.OTHR.ZS.UN”
[14,] “NV.MNF.TXTL.ZS.UN”
[15,] “SE.TER.GRAD.EN.FE.ZS”
[16,] “SE.TER.GRAD.EN.ZS”
[17,] “SE.TER.GRAD.FE.EN.ZS”
[18,] “SL.MNF.0714.FE.ZS”
[19,] “SL.MNF.0714.MA.ZS”
[20,] “SL.MNF.0714.ZS”
[21,] “SL.MNF.WAGE.FM”
[22,] “UIS.E.56.F500”
[23,] “UIS.E.56.F500.F”
[24,] “UIS.FOSEP.56.F500”
[25,] “UIS.FOSEP.56.F500.F”
[26,] “UIS.G.56.F500.dcount”
[27,] “UIS.G.56.F500.dcount.F” name
[1,] “CO2 emissions from manufacturing industries and construction (million metric tons)”
[2,] “CO2 emissions from manufacturing industries and construction (% of total fuel combustion)”
[3,] “Manufacturing, value added (current US\()" [4,] "Manufacturing, value added (current LCU)" [5,] "Manufacturing, value added (constant 2000 US\))”
[6,] “Manufacturing, value added (annual % growth)”
[7,] “Manufacturing, value added (constant LCU)”
[8,] “Value added, manufacturing growth rate (%)”
[9,] “Manufacturing, value added (% of GDP)”
[10,] “Chemicals (% of value added in manufacturing)”
[11,] “Food, beverages and tobacco (% of value added in manufacturing)”
[12,] “Machinery and transport equipment (% of value added in manufacturing)”
[13,] “Other manufacturing (% of value added in manufacturing)”
[14,] “Textiles and clothing (% of value added in manufacturing)”
[15,] “Graduates in engineering, manufacturing and construction, female (% of total female graduates, tertiary)” [16,] “Graduates in engineering, manufacturing and construction (% of total graduates, tertiary)”
[17,] “Female share of graduates in engineering, manufacturing and construction (%, tertiary)”
[18,] “Child employment in manufacturing, female (% of female economically active children ages 7-14)”
[19,] “Child employment in manufacturing, male (% of male economically active children ages 7-14)”
[20,] “Child employment in manufacturing (% of economically active children ages 7-14)”
[21,] “Ratio of female to male wages in manufacturing (%)”
[22,] “Enrolment in engineering, manufacturing and construction. Tertiary. Total”
[23,] “Enrolment in engineering, manufacturing and construction. Tertiary. Female”
[24,] “Percentage of tertiary enrolments (ISCED 5 and 6) in engineering, manufacturing and construction”
[25,] “Percentage of female tertiary enrolments (ISCED 5 and 6) in engineering, manufacturing and construction” [26,] “Graduates in engineering, manufacturing and construction. Tertiary. Total”
[27,] “Graduates in engineering, manufacturing and construction. Tertiary. Female”