CityPopularity
#
CityPopularity#
## Add the mean#
CityPopularity$Mean=mean(CityPopularity$Popularity)#
#
C1 <- gvisComboChart(CityPopularity, xvar="City",#
                                     yvar=c("Mean", "Popularity"),#
                                   options=list(seriesType="bars",#
                                                series='{0: {type:"line"}}'))#
plot(C1)
#
C1 <- gvisComboChart(CityPopularity, xvar="City",#
                                     yvar=c("Mean", "Popularity"),#
                                   options=list(seriesType="bars",#
                                                title="City Popularity",#
                                                series='{0: {type:"line"}}'))#
plot(C1)
df=data.frame(country=c("US", "GB", "BR"), val1=c(1,3,4), val2=c(23,12,32))
Combo <- gvisComboChart(df, xvar="country",#
                                     yvar=c("val1", "val2"),#
                                   options=list(seriesType="bars",#
                                                series='{0: {type:"line"}}'))#
plot(Combo)
#
Combo <- gvisComboChart(df, xvar="country",#
                                     yvar=c("val1", "val2"),#
                                   options=list(seriesType="bars",#
                                                series='{1: {type:"line"}}'))#
plot(Combo)
df=data.frame(country=c("US", "GB", "BR"), val1=c(10,13,14), val2=c(23,12,32))#
#
## Line chart#
Line <- gvisLineChart(df)#
plot(Line)
Bar <- gvisBarChart(df)
plot(Bar)
Column <- gvisColumnChart(df)#
plot(Column)
Area <- gvisAreaChart(df)#
plot(Area)
Combo <- gvisComboChart(df, xvar="country",#
                                     yvar=c("val1", "val2"),#
                                   options=list(seriesType="bars",#
                                                series='{1: {type:"line"}}'))#
plot(Combo)
cars
Scatter <- gvisScatterChart(cars, options=list(legend="none",#
                 lineWidth=2, pointSize=0, hAxis.title="weight",#
                 title="Women", vAxis="{title:'height'}",#
                 hAxis="{title:'weight'}")#
                 )#
plot(Scatter)
#
## Pie chart#
Pie <- gvisPieChart(CityPopularity)#
plot(Pie)
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300))#
plot(Gauge)
Geo=gvisGeoChart(Exports, locationvar="Country", numvar="Profit")#
plot(Geo)
?gvisGeoChart
library(googleVis)
?gvisGeoChart
demo(googleVis)
Org <- gvisOrgChart(Regions, options=list(width=600, height=300,#
                               size='large', allowCollapse=TRUE))#
plot(Org)
Org <- gvisOrgChart(Regions, options=list(width=600, height=250,#
                               size='large', allowCollapse=TRUE))#
plot(Org)
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300, width=600, height=300))#
plot(Gauge)
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300, width=400, height=300))#
plot(Gauge)
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))
plot(M)
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                 tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)
GTM
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)
GTM
rm(list=ls())
library(googleVis)
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)
GT
GTM
library(googleVis)
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)
library(googleVis)
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)
GT
GTM
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=TRUE)
plot(GT)
gvisMerge(GT, M)
M
GTM
GTM$html$header
cat(GTM$html$header)
cat(GTM$html$header$chart)
cat(GTM$html$chart)
cat(GTM$html$chart["jsData"])
cat(GTM$html$header)
cat(GTM$html$chart)
names(GTM$html$chart)
GT$html$chart["jsHeader"]
names(GT$html$chart)
library(googleVis)
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=TRUE)
names(GT$html$chart)
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)
#
M <- gvisMotionChart(Fruits, "Fruit", "Year")#
str(M)#
## The output for a complete web page#
M#
#
## Access only the plot,#
M$html$chart#
#
## wrap it in cat and it becomes more readable,#
cat(unlist(M$html$chart))#
#
## or use the print function.#
print(M, "chart")#
#
## Extract the data as a JavaScript function.#
print(M, "jsData")#
#
## Display the visualisation.#
## A web browser with Internet connection and Flash is required.#
plot(M)#
#
## Combine with another chart, e.g. table#
tbl <- gvisTable(Fruits)#
#
Mtbl <- gvisMerge(M, tbl)#
plot(Mtbl)
Fruits	#
## timevar Year#
M1 <- gvisMotionChart(Fruits, idvar="Fruit", timevar="Year")#
str(M1)#
## print.gvis, will concatenate the list into a one long string#
M1#
#
plot(M1)#
#
## Combine with another chart, e.g. table#
tbl <- gvisTable(Fruits)#
Mtbl <- gvisMerge(M1, tbl)#
plot(Mtbl)
tbl <- gvisTable(Fruits, options=list(height=200))#
Mtbl <- gvisMerge(M1, tbl)#
plot(Mtbl)
tbl <- gvisTable(Fruits, options=list(height=230))#
Mtbl <- gvisMerge(M1, tbl)#
plot(Mtbl)
tbl <- gvisTable(Fruits, options=list(height=220))#
Mtbl <- gvisMerge(M1, tbl)#
plot(Mtbl)
readLines()
?readLines
x="'Weekday', 'Low', 'Open', 'Close', 'High'#
'Mon',20,28,38,45,#
'Tues',31,38,55,66,#
'Wed',50,55,77,80,#
'Thurs',50,77,66,77,#
'Fri',15,66,22,68"
readLines(x)
cat(x, file="Stock.csv")
read.csv("Stock.csv")
x="Weekday, Low, Open, Close, High#
Mon,20,28,38,45,#
Tues,31,38,55,66,#
Wed,50,55,77,80,#
Thurs,50,77,66,77,#
Fri,15,66,22,68"
cat(x, file="Stock.csv")
read.csv("Stock.csv")
x="Weekday, Low, Open, Close, High#
Mon,20,28,38,45#
Tues,31,38,55,66#
Wed,50,55,77,80#
Thurs,50,77,66,77#
Fri,15,66,22,68"
cat(x, file="Stock.csv")
read.csv("Stock.csv")
OpenClose=read.csv("Stock.csv")
OpenClose
x
cat(x)
readLines(cat(x))
readLines(x)
scan(x)
readLines(n=5)
scan()
OpenClose
save(OpenClose, file="~/Dropbox/google-motion-charts-with-r/data/OpenClose.Rdata")
library(googleVis)
OpenVis
OpenClose
Stock
data(OpenClose)
OpenClose
library(googleVis)
OpenClose
read.csv("Stock.csv")
OpenCLose=read.csv("Stock.csv")
library(googleVis)
OpenClose
prompt(OpenClose, "~/Dropbox/google-motion-charts-with-r/man/OpenClose.Rd")
plot(gvisCandlestickChart(OpenClose, options=list(legend='none')))
plot(gvisCandlestickChart(OpenClose, options=list(legend='none', width=300, height=120)))
plot(gvisCandlestickChart(OpenClose, options=list(legend='none', width=300, height=150)))
plot(gvisCandlestickChart(OpenClose, options=list(legend='none')))
Candle <- gvisCandlestickChart(OpenClose, options=list(legend='none'))#
plot(Candle)
plot(gvisLineChart(OpenClose))
plot(gvisLineChart(OpenClose, "Weekday"))
plot(gvisAreaChart(OpenClose, "Weekday"))
plot(gvisAreaChart(OpenClose, "Weekday", "Open"))
plot(gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"))
)
plot(gvisLineChart(OpenClose, "Weekday", c("Open", "Close")))
plot(gvisScatterChart(OpenClose, "Low", c("Open", "Close")))
plot(gvisScatterChart(OpenClose, "Low", "Open", "Close"))
gvisScatterChart(OpenClose[,-1])
plot(gvisScatterChart(OpenClose[,-1]))
OpenClose
plot(gvisLineChart(OpenClose, "Weekday", c("Open", "Close")))
plot(gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"))0
plot(gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"))
)
plot(gvisBarChart(OpenClose, "Weekday", c("Open", "Close")))
plot(gvisColumnChart(OpenClose, "Weekday", c("Open", "Close")))
bar=gvisColumnChart(OpenClose, "Weekday", c("Open", "Close")))
bar=gvisColumnChart(OpenClose, "Weekday", c("Open", "Close"))
line=gvisLineChart(OpenClose, "Weekday", c("Open", "Close"))
column=gvisColumnChart(OpenClose, "Weekday", c("Open", "Close"))
bar=gvisBarChart(OpenClose, "Weekday", c("Open", "Close"))
area=gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"))
plot(gvisMerge(gvisMerge(gvisMerge(line, bar), column, TRUE), area, TRUE))
plot(gvisMerge(gvisMerge(gvisMerge(line, bar, TRUE), column, TRUE), area))
bar=gvisBarChart(OpenClose, "Weekday", c("Open", "Close"))
line=gvisLineChart(OpenClose, "Weekday", c("Open", "Close"), options=list(legend='none', width=300, height=150))
column=gvisColumnChart(OpenClose, "Weekday", c("Open", "Close"), options=list(legend='none', width=300, height=150))
area=gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"), options=list(legend='none', width=300, height=150))
bar=gvisBarChart(OpenClose, "Weekday", c("Open", "Close"), options=list(legend='none', width=300, height=150))
plot(gvisMerge(gvisMerge(line, bar), gvisMerge(column, area), TRUE))
#
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)#
#
#
line <- gvisLineChart(OpenClose, "Weekday", c("Open", "Close"), #
	      options=list(legend='none', width=300, height=150))#
column <- gvisColumnChart(OpenClose, "Weekday", c("Open", "Close"),#
              options=list(legend='none', width=300, height=150))#
area <- gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"),#
              options=list(legend='none', width=300, height=150))#
bar <- gvisBarChart(OpenClose, "Weekday", c("Open", "Close"),#
              options=list(legend='none', width=300, height=150))#
LBCA <- gvisMerge(gvisMerge(line, bar), gvisMerge(column, area), TRUE) #
#
plot(LBCA)#
#
plot(gvisMerge(GTM, LBCA))
,tableOptions="bgcolor=\"#CCCCCC
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCCC\"))
)
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCCC\"))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCCC\""))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10"))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCFF\")
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCFF\"")
)
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCFF\""))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCBB\""))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCAA\""))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCCCBB\""))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#CCAABB\""))
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#AABBCC\""))
#
G <- gvisGeoChart(Exports, "Country", "Profit", #
                  options=list(width=200, height=100))#
T <- gvisTable(Exports, #
                  options=list(width=200, height=260))#
#
GT <- gvisMerge(G,T, horizontal=FALSE) #
plot(GT)#
#
M <- gvisMotionChart(Fruits, "Fruit", "Year",#
                     options=list(width=400, height=360))#
#
GTM <- gvisMerge(GT, M, horizontal=TRUE,#
                     tableOptions="bgcolor=\"#CCCCCC\" cellspacing=10")#
plot(GTM)#
#
#
line <- gvisLineChart(OpenClose, "Weekday", c("Open", "Close"), #
	      options=list(legend='none', width=300, height=150))#
column <- gvisColumnChart(OpenClose, "Weekday", c("Open", "Close"),#
              options=list(legend='none', width=300, height=150))#
area <- gvisAreaChart(OpenClose, "Weekday", c("Open", "Close"),#
              options=list(legend='none', width=300, height=150))#
bar <- gvisBarChart(OpenClose, "Weekday", c("Open", "Close"),#
              options=list(legend='none', width=300, height=150))#
LBCA <- gvisMerge(gvisMerge(line, bar), gvisMerge(column, area), TRUE) #
#
plot(LBCA)#
#
#
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#AABBCC\""))
library(googleVis)
plot(gvisMerge(GTM, LBCA, tableOptions="bgcolor=\"#AABBCC\""))
bar=gvisBarChart(OpenClose, "Weekday", c("Open", "Close"))
plot(bar)
print(bar, "~/Dropbox/Public/bar.html")
print(bar, file="~/Dropbox/Public/bar.html")
x=plot(bar)
library(googleVis)
bar=gvisBarChart(OpenClose, "Weekday", c("Open", "Close"))
print(bar, file="~/Dropbox/Public/bar.html")
print(bar, file="~/Dropbox/Public/bar.html")
x=plot(bar)
print(bar, file="~/Dropbox/Public/bar.html")
x=plot(bar)
library(lattice)
example(barley)
head(barely)
head(barley)
?OpenClose
example(gvisMerge)
?gvisCandlestickChart
plot(gvisCandlestickChart(OpenClose, options=list(legend='none')))
plot(gvisCandlestickChart(OpenClose[,1:4], options=list(legend='none')))
plot(gvisCandlestickChart(OpenClose, "Weekday","Close","Low", "High", "Open", options=list(legend='none')))
gvisScatterChart(OpenClose)
getwd()
setwd("~/Dropbox/google-motion-charts-with-r/inst/gadgets/")
Geo=gvisGeoMap(Exports, locationvar="Country", numvar="Profit",#
                       options=list(dataMode='regions'))
plot(Geo)
AndrewGeo <- gvisGeoMap(Andrew, locationvar="LatLong", numvar="Speed_kt", #
      			 hovervar="Category", #
      		         options=list(height=250, width=400, region="US"))
plot(AndrewGeo)
AndrewMap <- gvisMap(Andrew, "LatLong" , "Tip", #
      	      options=list(showTip=TRUE, showLine=TRUE, enableScrollWheel=TRUE,#
		      mapType='terrain', useMapTypeControl=TRUE))
plot(AndrewMap)
Table <- gvisTable(Exports, options=list(width=400, height=300))
plot(Table)
Table <- gvisTable(Exports, options=list(width=400, height=270))
plot(Table)
Tree <- gvisTreeMap(Regions,  "Region", "Parent", "Val", "Fac", options=list(fontSize=16))
plot(Tree)
PopTable <- gvisTable(Population, options=list(width=600, height=300, page='enable'))
plot(PopTable)
Tree <- gvisTreeMap(Regions,  "Region", "Parent", "Val", "Fac",#
                    options=list(fontSize=16, width=400, height=300))
plot(Tree)
require(datasets)#
states <- data.frame(state.name, state.area)#
#
states3 <- data.frame(state.region, state.division, state.name, state.area)#
#
regions <- aggregate(list(region.area=states3$state.area),#
                     list(region=state.region), sum)#
#
divisions <- aggregate(list(division.area=states3$state.area),#
                     list(division=state.division, region=state.region),#
                     sum)#
#
my.states3 <- data.frame(regionid=c("USA",#
                                    as.character(regions$region),#
                                    as.character(divisions$division),#
                                    as.character(states3$state.name)),#
                         parentid=c(NA, rep("USA", 4), #
                                   as.character(divisions$region),#
                                   as.character(states3$state.division)),#
                         state.area=c(sum(states3$state.area),#
                                      regions$region.area,#
                                      divisions$division.area,#
                                      states3$state.area))#
#
my.states3$state.area.log=log(my.states3$state.area)#
#
statesTree3 <- gvisTreeMap(my.states3, "regionid", "parentid",#
                           "state.area", "state.area.log", options=list(showScale=TRUE, width=400, height=300))
plot(statesTree3)
df=data.frame(country=c("US", "GB", "BR"), val1=c(1,3,4), val2=c(23,12,32))#
#
## Line chart#
Line <- gvisLineChart(df,#
                options=list(legend='none', width=300, height=150))
plot(Line)
Line <- gvisLineChart(df,#
                options=list(legend='none', width=300, height=200))
plot(Line)
Bar <- gvisBarChart(df,#
                    options=list(legend='none', width=300, height=150))
plot(Bar)
Bar <- gvisBarChart(df,#
                    options=list(legend='none', width=300, height=200))
plot(Bar)
Column <- gvisColumnChart(df,#
                          options=list(legend='none', width=300, height=200))
plot(Column)
Area <- gvisAreaChart(df,#
                      options=list(legend='none', width=300, height=300))
plot(Area)
Scatter <- gvisScatterChart(women, options=list(legend="none",#
                 lineWidth=2, pointSize=0, hAxis.title="weight",#
                 title="Women", vAxis="{title:'height'}",#
                 hAxis="{title:'weight'}", width=300, height=150))
plot(Scatter)
## Scatter chart#
Scatter <- gvisScatterChart(women, options=list(legend="none",#
                 lineWidth=2, pointSize=0, hAxis.title="weight",#
                 title="Women", vAxis="{title:'height'}",#
                 hAxis="{title:'weight'}", width=300, height=300))
plot(Scatter)
Pie <- gvisPieChart(CityPopularity,#
                    options=list(legend='none', width=300, height=150))
plot(Pie)
Pie <- gvisPieChart(CityPopularity,#
                    options=list(width=300, height=200))
plot(Pie)
Pie <- gvisPieChart(CityPopularity,#
                    options=list(width=400, height=200))
plot(Pie)
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300, width=300, height=150))
plot(Gauge)
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300, width=300, height=250))
plot(Gauge)
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300, width=300, height=220))
plot(Gauge)
Intensity <- gvisIntensityMap(df,#
                              options=list(legend='none', width=300, height=200))
plot(Intensity)
Intensity <- gvisIntensityMap(df)
plot(Intensity)
Org <- gvisOrgChart(Regions, options=list(width=600, height=200,#
                               size='large', allowCollapse=TRUE))
plot(Org)
Org <- gvisOrgChart(Regions, options=list(width=600, height=210,#
                               size='large', allowCollapse=TRUE))
plot(Org)
Candle <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",#
                                      open="Open", close="Close",#
                                      high="High",#
                                      options=list(legend='none',#
                                        wdith=300, height=200))
plot(Candle)
## Candlestick chart#
Candle <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",#
                                      open="Open", close="Close",#
                                      high="High",#
                                      options=list(legend='none',#
                                        wdith=300, height=300))
plot(Candle)
Candle <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",#
                                      open="Open", close="Close",#
                                      high="High",#
                                      options=list(legend='none',#
                                        wdith=200, height=200))
plot(Candle)
Candle <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",#
                                      open="Open", close="Close",#
                                      high="High",#
                                      options=list(legend='none',#
                                        with=300, height=200))
plot(Candle)
Candle <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",#
                                      open="Open", close="Close",#
                                      high="High",#
                                      options=list(legend='none',#
                                        with=300, height=250))
plot(Candle)
## Move into the inst/gadget folder before you run this script!#
#
Motion=gvisMotionChart(Fruits, idvar="Fruit", timevar="Year",#
  options=list(height=350, width=400)) #
cat(createGoogleGadget(Motion), file="motionchart.xml")#
#
## Geo Map with coloured regions#
Geo=gvisGeoMap(Exports, locationvar="Country", numvar="Profit",#
                       options=list(dataMode='regions'))#
#
cat(createGoogleGadget(Geo), file="geomap.xml")##
#
## Show Hurricane Andrew (1992) storm track with Geo Map#
AndrewGeo <- gvisGeoMap(Andrew, locationvar="LatLong", numvar="Speed_kt", #
      			 hovervar="Category", #
      		         options=list(height=250, width=400, region="US"))#
#
cat(createGoogleGadget(AndrewGeo), file="andrewgeomap.xml")#
#
## Hurricane Andrew (1992) storm track with Google Maps#
AndrewMap <- gvisMap(Andrew, "LatLong" , "Tip", #
      	      options=list(showTip=TRUE, showLine=TRUE, enableScrollWheel=TRUE,#
		      mapType='terrain', useMapTypeControl=TRUE))#
#
cat(createGoogleGadget(AndrewMap), file="andrewmap.xml")#
#
#
## Table. Click on the column header to sort the rows #
Table <- gvisTable(Exports, options=list(width=400, height=270))##
cat(createGoogleGadget(Table), file="table.xml")#
#
## Table with embedded links#
PopTable <- gvisTable(Population, options=list(width=600, height=300, page='enable'))##
#
cat(createGoogleGadget(PopTable), file="poptable.xml")#
#
## Tree Map. Left mouse-click to drill down, right mouse-click to move up a hierarchy#
Tree <- gvisTreeMap(Regions,  "Region", "Parent", "Val", "Fac",#
                    options=list(fontSize=16, width=400, height=300)) ##
#
cat(createGoogleGadget(Tree), file="treemap.xml")#
#
require(datasets)#
states <- data.frame(state.name, state.area)#
#
states3 <- data.frame(state.region, state.division, state.name, state.area)#
#
regions <- aggregate(list(region.area=states3$state.area),#
                     list(region=state.region), sum)#
#
divisions <- aggregate(list(division.area=states3$state.area),#
                     list(division=state.division, region=state.region),#
                     sum)#
#
my.states3 <- data.frame(regionid=c("USA",#
                                    as.character(regions$region),#
                                    as.character(divisions$division),#
                                    as.character(states3$state.name)),#
                         parentid=c(NA, rep("USA", 4), #
                                   as.character(divisions$region),#
                                   as.character(states3$state.division)),#
                         state.area=c(sum(states3$state.area),#
                                      regions$region.area,#
                                      divisions$division.area,#
                                      states3$state.area))#
#
my.states3$state.area.log=log(my.states3$state.area)#
#
statesTree3 <- gvisTreeMap(my.states3, "regionid", "parentid",#
                           "state.area", "state.area.log", options=list(showScale=TRUE, width=400, height=300))#
#
cat(createGoogleGadget(statesTree3), file="statestreemap.xml")#
#
#
## Annotated Time Line Chart#
AnnoTimeLine  <- gvisAnnotatedTimeLine(Stock, datevar="Date",#
                           numvar="Value", idvar="Device",#
                           titlevar="Title", annotationvar="Annotation",#
                           options=list(displayAnnotations=TRUE,#
                             legendPosition='newRow',#
                             width=400, height=250)#
                           )#
cat(createGoogleGadget(AnnoTimeLine), file="annotimeline.xml")#
#
## Sample data#
df=data.frame(country=c("US", "GB", "BR"), val1=c(1,3,4), val2=c(23,12,32))#
#
## Line chart#
Line <- gvisLineChart(df,#
                options=list(legend='none', width=300, height=200))#
cat(createGoogleGadget(Line), file="linechart.xml")#
#
#
## Bar chart#
Bar <- gvisBarChart(df,#
                    options=list(legend='none', width=300, height=200))#
cat(createGoogleGadget(Bar), file="barchart.xml")#
#
## Column chart#
Column <- gvisColumnChart(df,#
                          options=list(legend='none', width=300, height=200))#
cat(createGoogleGadget(Column), file="columnchart.xml")#
#
## Area chart#
Area <- gvisAreaChart(df,#
                      options=list(legend='none', width=300, height=300))#
cat(createGoogleGadget(Area), file="areachart.xml")#
#
## Scatter chart#
Scatter <- gvisScatterChart(women, options=list(legend="none",#
                 lineWidth=2, pointSize=0, hAxis.title="weight",#
                 title="Women", vAxis="{title:'height'}",#
                 hAxis="{title:'weight'}", width=300, height=300))#
                 #
cat(createGoogleGadget(Scatter), file="scatterchart.xml")#
#
## Pie chart#
Pie <- gvisPieChart(CityPopularity,#
                    options=list(width=400, height=200))#
cat(createGoogleGadget(Pie), file="piechart.xml")#
#
## Gauge#
Gauge <-  gvisGauge(CityPopularity, options=list(min=0, max=800, greenFrom=500,#
                                      greenTo=800, yellowFrom=300, yellowTo=500,#
                                      redFrom=0, redTo=300, width=300, height=220))#
cat(createGoogleGadget(Gauge), file="gauge.xml")#
#
## Intensity Map#
Intensity <- gvisIntensityMap(df)#
#
cat(createGoogleGadget(Intensity), file="intensitymap.xml")#
#
## Org chart#
Org <- gvisOrgChart(Regions, options=list(width=600, height=210,#
                               size='large', allowCollapse=TRUE))#
cat(createGoogleGadget(Org), file="orgchart.xml")#
#
## Candlestick chart#
Candle <- gvisCandlestickChart(OpenClose, xvar="Weekday", low="Low",#
                                      open="Open", close="Close",#
                                      high="High",#
                                      options=list(legend='none',#
                                        with=300, height=250))#
#
cat(createGoogleGadget(Candle), file="candlestickchart.xml")
?createGoogleGadget
