Last updated on Sat Aug 1 14:28:00 2015

This page contains a list of resources for the IRIS DMC R Workshop conducted on May 5-7, 2015.

Learning R

Books and blog posts

  • Simple R – John Verzani’s excellent introduction to R for introductory statistics
  • Broman Tutorials – Karl Broman has a number of very simple tutorials, mostly on R
  • Working With Data: Using R – Jon Callahan’s series of blog posts on specific R topics
  • PWFSL Class – Mazama Science 2014 workshop for wildfire scientists (dplyr, ncdf, lubridate, openair)
  • IRIS Class – Mazama Science 2014 workshop for seismologists (stringr, lubridate, seismicRoll, IRISSeismic, IRISMustangMetrics)
  • Data Cleaning – Statistic Netherlands 2013 overview of data ingest and cleaning
  • Cookbook for R – Winston Chang’ (from rstudio.com)’s cookbook with lots of ggplot2 examples
  • The R Inferno – Patrick Burns 2011 guide to R pitfalls and how to avoid them
  • Advanced R – Hadley Wickham’s book on advanced topics in R
  • R Packages – Hadley Wickham’s 2015 book on writing R packages

Cheatsheets


Choosing Packages

When picking packages to use the first rule should be to always default to the hadleyverse: use any package that Hadley Wickham has been involved with. Important packages include: stringr, lubridate, dplyr, reshape2, ggplot2, roxygen2.

The second rule is to peruse CRAN Task Views. These topic-related pages are maintained by recognized authorities in the R community and are a great place to get an overview of what packages are available for which sort of task.

Finally, if you are going to be a regular user of R, it is worth looking at R-bloggers. This is a searchable blog aggregator and is the best place to go for up-todate information and examples as well as news about the latest package releases.


Workshop Topics of Interest

Several topics of interest came up during the workshop. The links below will give people a few starting points from which to begin exploring each topic.

Maps

R’s support for generating maps falls under the Analysis of Spatial Data task view. The simples implementation includes the map and mapdata packages which unfortunately use 1989 world borders. This means it includes the Soviet Union, Yugoslavia Czechoslovakia, Sudan, etc. – all countries that no longer exist.

Full GIS capabilities are supported by the sp and maptools packages. There is also a MazamaSpatialUtils package to make it easier to work with GIS layers.

Here is a quick examples from ?getEvent:

library(IRISSeismic)

# NOTE:  'maps' and 'mapdata' packages must be installed
library(maps)
library(mapdata)

# Open a connection to IRIS DMC webservices
iris <- new("IrisClient")

# Get events > mag 5.0 over a week in June of 2012
starttime <- as.POSIXct("2012-06-21", tz="GMT")
endtime <- starttime + 3600 * 24 * 7
events <- getEvent(iris, starttime, endtime, minmag=5.0)

# Look at all events
print(paste(nrow(events),"earthquakes found with magnitude > 5.0"))
## [1] "26 earthquakes found with magnitude > 5.0"
# Plot events on a map
map('world')
points(events$longitude, events$latitude, pch=16, cex=1.5, col='red')
labels <- paste(" ", as.character(round(events$magnitude,1)), sep="")
text(events$longitude, events$latitude, labels=labels, pos=4, cex=1.2, col='red3')

The maps package does support some projections but much better support is proved by the sp package. The following links provide some starting points for exploring maps:

Complex Metrics

Signal Processing

The Numerical Mathematics task view is the place to start looking for packages for singal processing. Key among these, and two that the IRISSeismic package uses are pracma for ‘practical math’ and signal for signal processing, both of which contain R ports of many routines found in MATLAB.

There is also a Time Series task view with potentially useful packages.

Optimization

Operational Issues

Running R scripts operationally usually means launching them from a cron job. This requires stand-alone executable scripts that accept arguments and than have appropriate error handling code.

ADD MORE HERE


10: Modifying Seismic Packages < prev | next >