[R] error with geomap in googleVis
Mike Marchywka
marchywka at hotmail.com
Fri Jun 10 12:33:48 CEST 2011
----------------------------------------
> Subject: RE: [R] error with geomap in googleVis
> Date: Fri, 10 Jun 2011 11:06:47 +0100
> From: Markus.Gesmann at lloyds.com
> To: marchywka at hotmail.com; r-help at stat.math.ethz.ch
>
> Hi Mike,
>
> I believe you are trying to put two charts on the same page.
> The demo(googleVis) provides you with an example for this.
> So applying the same approach to your data sets would require:
Thanks, I thought however I tried to different examples the first
being my own which failed and then the "Fruits" example as a second
test. I was lazy and used install package from probably wrong mirror
as in the past on 'dohs I had problems with CMD INSTALL. I reloaded
as per your suggestion and tried first example. The output did
change but it is still lacking a chart. Do I need API key or something?
Ive never used google visualization before and was just reacting to OP
as I had wanted to try it. Process is below, final result may
be here, http://98.129.232.232/xxx.html , but I will be varying as
I get time. Thanks again.
--2011-06-10 05:17:47-- http://cran.r-project.org/src/contrib/googleVis_0.2.5.t
ar.gz
Resolving cran.r-project.org... 137.208.57.37
Connecting to cran.r-project.org|137.208.57.37|:80... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Date: Fri, 10 Jun 2011 10:17:47 GMT
Server: Apache/2.2.9 (Debian)
Last-Modified: Tue, 07 Jun 2011 06:35:56 GMT
ETag: "a83451-b36e9-4a5196ea64b00"
Accept-Ranges: bytes
Content-Length: 734953
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/x-gzip
Length: 734953 (718K) [application/x-gzip]
Saving to: `googleVis_0.2.5.tar.gz'
100%[======================================>] 734,953 527K/s in 1.4s
2011-06-10 05:17:49 (527 KB/s) - `googleVis_0.2.5.tar.gz' saved [734953/734953]
[marchywka at 351915-www1 downloads]$ R CMD INSTALL googleVis_0.2.5.tar.gz
* installing to library `/usr/local/lib64/R/library'
* installing *source* package `googleVis' ...
** R
** data
** moving datasets to lazyload DB
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices ...
** testing if installed package can be loaded
* DONE (googleVis)
[marchywka at 351915-www1 downloads]$ R
R version 2.13.0 (2011-04-13)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> library(googleVis)
df<-data.frLoading required package: RJSONIO
ame(foo=c("BrazilTo suppress the following message use the statement:
suppressPackageStartupMessages(library(googleVis))
Welcome to googleVis version 0.2.5
Type ?googleVis to access the overall documentation and
vignette('googleVis') for the package vignette.
You can execute the demo of the package via: demo(googleVis)
More information is available on the googleVis project web-site:
http://code.google.com/p/google-motion-charts-with-r/
Please read also the Google Visualisation API Terms of Use:
http://code.google.com/apis/visualization/terms.html
Feel free to send us an email <rvisualisation at gmail.com>
if you would like to be keept informed of new versions,
or if you have any feedback, ideas, suggestions or would
like to collaborate.
","C> df<-data.frame(foo=c("Brazil","Canada"), bar=c(123,456))
>
> map1<-gvisGeoMap(df,locationvar='foo',numvar='bar')
> cat(map1$html)
Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'list') cannot be handled by 'cat'
> cat(map1$html$header)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>GeoMapID23b504e5</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
body {
color: #444444;
font-family: Arial,Helvetica,sans-serif;
font-size: 75%;
}
a {
color: #4D87C7;
text-decoration: none;
}
</style>
</head>
<body>
> cat(map1$html$header,file="xxx.html",appeand=F)
> cat(map1$html$chart,file="xxx.html",appeand=t)
Error in cat(list(...), file, sep, fill, labels, append) :
argument 2 (type 'closure') cannot be handled by 'cat'
> str(map1$html)
List of 4
$ header : chr "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<ht"| __truncated__
$ chart : Named chr [1:7] "<!-- GeoMap generated in R 2.13.0 by googleVis 0.2.
5 package -->\n<!-- Fri Jun 10 05:20:25 2011 -->\n\n\n<!-- jsHeader -->\n<sc"| _
_truncated__ "\n// jsData \nfunction gvisDataGeoMapID23b504e5 ()\n{\n var data
= new google.visualization.DataTable();\n var datajson =\n[\"| __truncated__ "\
n// jsDrawChart\nfunction drawChartGeoMapID23b504e5() {\n var data = gvisDataGe
oMapID23b504e5()\n var chart = new google.vis"| __truncated__ "\n// jsDisplayCh
art \nfunction displayChartGeoMapID23b504e5()\n{\n google.load(\"visualization\
", \"1\", { packages:[\"geomap\"| __truncated__ ...
..- attr(*, "names")= chr [1:7] "jsHeader" "jsData" "jsDrawChart" "jsDisplayCh
art" ...
$ caption: chr "<div><span>Data: df • Chart ID: <a href=\"Chart_GeoMapID2
3b504e5.html\">GeoMapID23b504e5</a></span><br />"
$ footer : chr "\n<!-- htmlFooter -->\n<span> \nR version 2.13.0 (2011-04-13) &
#8226; <a href=\"http://code.google.com/p/google-motion-charts-w"| __truncated__
> cat(map1$html$chart,file="xxx.html",appeand=T)
> cat(map1$html$caption,file="xxx.html",appeand=T)
> cat(map1$html$footer,file="xxx.html",appeand=T)
> cat(map1$html$header,file="xxx.html",appeand=F)
> cat(map1$html$chart,file="xxx.html",appeand=F)
> cat(map1$html$header,file="xxx.html",appeand=F)
> cat(map1$html$chart,file="xxx.html",appeand=T)
> cat(map1$html$footer,file="xxx.html",appeand=T)
>
>
> library(googleVis)
> df<-data.frame(foo=c("Brazil","Canada"), bar=c(123,456))
>
> map1<-gvisGeoMap(df,locationvar='foo',numvar='bar')
> m<-gvisMotionChart(Fruits,idvar="Fruit",timevar="Year")
>
> ## Build a new gvis object based on the exsiting ones
> ComboChart <- structure(list(type='GeoMapMotionChart',
> chartid='myComboChart',
> html=list(header=map1$html$header,
> chart=list(map1$html$chart, # Geo Map
> m$html$chart), # Motion Chart
> caption="Combination of various googleVis outputs
More information about the R-help
mailing list