googleVis 0.2.17 is released: Displaying earth quake data

August 13, 2012

(This article was first published on mages' blog, and kindly contributed to R-bloggers)

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 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 
## Get earthquake data of the last 30 days
eq <- readHTMLTable(readLines(""),
 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",
                   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

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")

## 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. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , , , ,

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training




CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

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)