Blog Archives

Basic text string functions in R

May 18, 2015
By

To get the length of a text string (i.e. the number of characters in the string): Using length() would just give you the length of the vector containing the string, which will be 1 if the string is just a single string. To get the position of a regular expression match(es) in a text string

Read more »

A plot of co-authorships in my little corner of science

April 22, 2015
By

  Here’s a mostly useless visualization of the collection of journal articles that sits in my reference database in Endnote. I deal mostly in marine biology, physiology, biomechanics, and climate change papers, with a few molecular/genetics papers thrown in here and there. The database has 3325 entries, 2 of which have ambiguous publication years and

Read more »

Extracting NOAA sea surface temperatures with ncdf4

November 25, 2014
By

I’ve written previously about some example R scripts I created to extract sea surface temperature data from NOAA’s Optimum Interpolated Sea Surface Temperature products. If you want daily global sea surface temperatures on a 0.25×0.25° grid, they gather those into 1-year files available at http://www.esrl.noaa.gov/psd/data/gridded/data.noaa.oisst.v2.highres.html. If you want weekly average SST values on a 1×1°

Read more »

NOAA OISST v2 High Resolution daily sea surface temperatures with R

January 13, 2014
By

The National Ocean and Atmospheric Administration generates freely-available world-wide estimates of mean daily sea surface temperature, and has been doing so back to 1981. The data are on a 0.25 x 0.25 degree grid, and provide an interpolated estimate of the sea surface temperature for each day of the year, based on a mix of

Read more »

Make your R figures legible in Powerpoint/Keynote presentations

January 12, 2014
By

Having just returned from the SICB 2014 meetings, the appearance of many people’s Powerpoint figures is fresh on my mind. The sheer number of tiny figure labels (tick marks, axis titles, legend text etc) is disappointing. If we want to point fingers, MATLAB users are clearly the worst offenders because of the microscopic default label

Read more »

Part 2: Make your R figures legible in Powerpoint/Keynote presentations

January 2, 2014
By

In the previous post, I outlined some tips for increasing the size of figure labels for figures that are meant to be displayed on a projector. The previous post used the base R plot() function, but the procedure when plotting with ggplot2 is different and usually quite a bit simpler than the stock R plotting

Read more »

More tide prediction with R

May 19, 2013
By

In the previous post I outlined how to query the XTide software with R and parse the results into a handy-dandy data frame. The biggest hurdle with that method is getting XTide up and running on your computer. The code outlined here works entirely within R, so you don’t need XTide installed on your computer.

Read more »

Interfacing XTide and R

May 17, 2013
By

XTide is an open-source program that predicts tide heights and current speeds for hundreds of tide and current stations around the United States. It can be used to produce tide predictions in the past and future for a site at your chosen interval (down...

Read more »

Book Review: The R Book, Second Edition (2013)

May 1, 2013
By

The first edition of The R Book by Michael J. Crawley was an ambitious work, but managed to be slightly rubbish due to the atrocious typographical layout of the original book. The good news is that the new 2nd edition, released in 2013, has a substanti...

Read more »

Generating polygon boundaries for plotting simple time series data with missing data

December 19, 2012
By

Every so often I want to plot some data with pretty upper and lower error bounds, such as temperature data through time, perhaps with the maximum and minimum temperature range or standard error bounds for averaged data. The polygon( ) function can make those sorts of pretty plots. However, I’ll often have chunks of missing

Read more »