googleVis 0.2.17 is released: Displaying earth quake data
The next version of the googleVis
package has been released on the project site and CRAN.
This version provides updates to the package vignette and a new example for the gvisMerge
function. The new sections of the vignette have been featured on this blog in more detail earlier:
- Using
googleVis
withknitr
(Link to post)
- Using
Rook
withgoogleVis
(Link to post)
- Using
Reduce
withgvisMerge
to display several charts on a page (Link to post)
Additionally two little bugs were fixed:
- Data frames with one row only were not displayed in a chart. Thanks to Oliver Jay and Wai Tung Ho for reporting this issue.
- The example in the
gvisGeoChart
help file, which scraps data from http://www.iris.edu/seismon/last30.html to display earth quakes of the last 30 days with magnitude ≥ 4.0, didn't display the magnitude correctly. The variable Mag was read as a factor rather than numeric. Thanks to Jason Law, who highlighted this point. Here is the now working example.
km
.## Plot world wide earth quakes of the last 30 days with magnitude >= 4.0
library(XML)
library(googleVis)
## Get earthquake data of the last 30 days
eq <- readHTMLTable(readLines("http://www.iris.edu/seismon/last30.html"),
colClasses=c("factor", rep("numeric", 4), "factor"), which=2)
## Create a lat:long location variable
eq$loc=paste(eq$LAT, eq$LON, sep=":")
## Create a geo chart
G <- gvisGeoChart(eq, "loc", "DEPTH km", "MAG",
options=list(displayMode="Markers",
colorAxis="{colors:['purple', 'red', 'orange', 'grey']}",
backgroundColor="lightblue"), chartid="EQ")
## Display geo chart in local web browser
fn <- plot(G)
## You find the HTML file fn here
fn
Setting the region argument to 'IR'
highlights the recent (11 August 2012) earth quake in north-west Iran near Tabriz and Ahar, which caused the death of hundreds and injured thousands.
IR <- gvisGeoChart(eq, "loc", "DEPTH km", "MAG",
options=list(displayMode="Markers", region="IR",
colorAxis="{colors:['purple', 'red', 'orange', 'grey']}",
backgroundColor="lightblue"), chartid="Iran")
plot(IR)
sessionInfo()
## R version 2.15.1 (2012-06-22)
## Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
##
## locale:
## [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] googleVis_0.2.17 RJSONIO_0.98-1 XML_3.9-4
##
## loaded via a namespace (and not attached):
## [1] tools_2.15.1
No comments :
Post a Comment