googleVis 0.2.17 is released: Displaying earth quake data

[This article was first published on mages' blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.


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:

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.


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

To leave a comment for the author, please follow the link and comment on their blog: mages' blog.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)