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)
- 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.
The size of the bubbles reflect the magnitude and the colour shows the depth of the earthquakes in 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
Citation
For attribution, please cite this work as:Markus Gesmann (Aug 13, 2012) googleVis 0.2.17 is released: Displaying earth quake data. Retrieved from https://magesblog.com/post/2012-08-13-googlevis-0217-is-released-displaying/
@misc{ 2012-googlevis-0.2.17-is-released-displaying-earth-quake-data,
author = { Markus Gesmann },
title = { googleVis 0.2.17 is released: Displaying earth quake data },
url = { https://magesblog.com/post/2012-08-13-googlevis-0217-is-released-displaying/ },
year = { 2012 }
updated = { Aug 13, 2012 }
}