This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
library(reshape2)
library(googleVis)
## Creating a generic function for 'toJSON' from package 'jsonlite' in package 'googleVis'
##
## Welcome to googleVis version 0.6.1
##
## Please read the Google API Terms of Use
## before you start using the package:
## https://developers.google.com/terms/
##
## Note, the plot method of googleVis will by default use
## the standard browser to display its output.
##
## See the googleVis package vignettes for more details,
## or visit http://github.com/mages/googleVis.
##
## To suppress this message use:
## suppressPackageStartupMessages(library(googleVis))
suppressPackageStartupMessages(library(googleVis))
chik <- read.csv('chikang.csv', header = TRUE)
head(chik)
## Years Andhra.Pradesh Arunachal.Pradesh Assam Bihar Goa Gujarat Haryana
## 1 2010 116 1 1 1 1429 1719 26
## 2 2011 99 1 1 91 664 1142 215
## 3 2012 2827 1 1 34 571 1317 9
## 4 2013 4827 1 742 1 1149 2891 1
## 5 2014 1359 1 1 1 1215 574 3
## 6 2015 817 35 1 3 561 416 1
## J.K Jharkhand Karnataka Kerala Madhya.Pradesh Meghalaya Maharashtra
## 1 1 1 8741 1718 113 16 7431
## 2 1 816 1941 183 281 168 5113
## 3 1 86 2382 66 21 1 1544
## 4 1 61 5295 273 139 1 1578
## 5 1 11 6962 272 161 1 1572
## 6 1 21 21763 175 67 78 391
## Orissa Punjab Rajasthan Tamil.nadu Telangana Tripura Uttar.Pradesh
## 1 544 1 1326 4319 1 1 5
## 2 236 1 618 4194 1 1 3
## 3 129 1 172 5118 1 1 13
## 4 35 1 76 859 1 1 1
## 5 11 2 51 543 1687 34 4
## 6 81 181 7 329 2167 181 1
## Uttarakhand West.Bengal Andaman Chandigarh D.N Delhi Lakshadweep
## 1 1 21513 59 1 1 121 1
## 2 18 4482 96 1 1 111 1
## 3 1 1381 256 1 111 6 1
## 4 1 646 212 1 2 18 1
## 5 1 1132 161 1 1 8 1
## 6 1 1113 68 1 1 64 1
## Puduchery
## 1 11
## 2 42
## 3 45
## 4 146
## 5 399
## 6 245
chikdf<- melt(chik, id.vars ="Years", States = c('Andhra.Pradesh', 'Arunachal.Pradesh', 'Assam', 'Bihar', 'Goa', 'Gujarat', 'Haryana', 'J.K', 'Jharkhand',
'Karnataka', 'Kerala', 'Madhya.Pradesh', 'Meghalaya', 'Maharashtra', 'Orissa', 'Punjab', 'Rajasthan', 'Tamil.nadu', 'Telangana',
'Tripura', 'Uttar.Pradesh', 'Uttarakhand', 'West.Bengal', 'Andaman', 'Chandigarh', 'D.N', 'Delhi', 'Lakshadweep', 'Puduchery'))
Chikangunya spread from 2010 to 2016:
M <- gvisMotionChart(chikdf, idvar="variable",
timevar="Years", options = list(width = 800, height = 450))
print(M, tag="chart")
Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.