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(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))
getOption("viewer", NULL)
## NULL
Chikangunya <- read.table("chikan2016new", header = TRUE,
sep="\t",
fill = TRUE,
strip.white = TRUE,
stringsAsFactors = TRUE,
na.strings = "EMPTY")
head(Chikangunya)
## States Cases
## 1 Andhra Pradesh 934
## 2 Arunachal Pradesh 239
## 3 Assam 38
## 4 Bihar 566
## 5 Goa 308
## 6 Gujarat 2920
Chikangunya <- Chikangunya[, c("States","Cases")]
ChikangunyaStateName <- Chikangunya[, "States"]
head(ChikangunyaStateName)
## [1] Andhra Pradesh Arunachal Pradesh Assam Bihar
## [5] Goa Gujarat
## 31 Levels: Andaman&Nicobar Islands Andhra Pradesh ... West Bengal
head(Chikangunya)
## States Cases
## 1 Andhra Pradesh 934
## 2 Arunachal Pradesh 239
## 3 Assam 38
## 4 Bihar 566
## 5 Goa 308
## 6 Gujarat 2920
ChikangunyaStates <- gvisGeoChart(Chikangunya, "States", "Cases", options=list(region="IN", displayMode="regions", resolution="provinces", colorAxis="{colors:['blue', 'grey']}", backgroundColor="lightblue"))
library(plyr)
Chikangunyatable <- read.csv("chiknew.csv", header = TRUE)
head(Chikangunyatable)
## States X2010 X2011 X2012 X2013 X2014 X2015 X2016
## 1 Andhra Pradesh 116 99 2827 4827 1359 817 934
## 2 Arunachal Pradesh 0 0 0 0 0 35 239
## 3 Assam 0 0 0 742 0 0 38
## 4 Bihar 0 91 34 0 0 3 566
## 5 Goa 1429 664 571 1049 1205 561 308
## 6 Gujarat 1709 1042 1317 2890 574 406 2920
chik2 <- rename(Chikangunyatable, c("X2010"="2010", "X2011"="2011","X2012"="2012", "X2013"="2013", "X2014"="2014", "X2015"="2015",
"X2016"="2016")) # rename column names
head(chik2)
## States 2010 2011 2012 2013 2014 2015 2016
## 1 Andhra Pradesh 116 99 2827 4827 1359 817 934
## 2 Arunachal Pradesh 0 0 0 0 0 35 239
## 3 Assam 0 0 0 742 0 0 38
## 4 Bihar 0 91 34 0 0 3 566
## 5 Goa 1429 664 571 1049 1205 561 308
## 6 Gujarat 1709 1042 1317 2890 574 406 2920
tab2 <- gvisTable(chik2, options = list(width = 600, height = 600,
page = "enable"))
Tbl <- tab2 <- gvisTable(chik2, options = list(width = 500, height = 400, page = "enable"))
You can also embed plots, for example:
print(gvisMerge(ChikangunyaStates, Tbl, horizontal = TRUE))
|
|
|
echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.