* You are viewing the archive for the ‘R-project’ Category

Plotting stuff on an image

Recently, I needed to figure out how many extension cords I was going to need to buy in order to reach parts of my field site. Wandering around in the field with a surveyor’s tape was an option, but so was plotting distances on an aerial image I had of my site. What follows is a brief walk through of how I plotted stuff on top of my image in R (the open-source statistical computer software language, available at http://www.r-project.org/).

My final image with elements overlain on the original image using R.

Continue Reading

Eclipse and StatET 2.0 Install For Running R

The Eclipse IDE with StatET plugin, developed by Stephen Wahlbrink, is one of the more (maybe the most) full-featured options for running R. I’ve written about this combination before (previous post), but the highlights include a script editor with syntax highlighting, code completion, an integrated graphics window, an advanced debug system, and the best object browser available among the various freely available R development environments. This post outlines the installation of the current StatET 2.0.x version on a Windows 7 x64 system, since the installation process has become slightly more streamlined since … Continue Reading

Loading OSU’s VGPM ocean productivity data in R

Oregon State University makes a set of ocean productivity data derived from satellite data available for download and use by researchers. The Ocean Productivity website explains the available data and how it was derived. I have put together a few R functions to open a subset of the available data files and plot the data.

Average monthly net primary productivity along the west coast of North America during February 2003. Data derived from OSU’s Vertically Generalized Production Model.

The data files used … Continue Reading

A simple ggplot2 scatterplot revisited

Rick Wicklin contacted me with a helpful suggestion for improving the data presentation method outlined in my  previous post on using ggplot2 to visualize some data. In the previous post I had plotted up a highly correlated set of points, showing the correspondence between maximum daily body temperatures of model snails sitting with the foot touching the rock surface, or withdrawn into the shell.

The original figure.

Rick points out that with a bit of data manipulation, you can replot these … Continue Reading

A simple ggplot2 scatterplot

Here’s a bit of code used to produce one of the figures in my recent paper dealing with modeling rocky intertidal snail body temperatures. This was my first foray into ggplot2, and it only involved a few hours of head-scratching. The plot is a comparison of 10 years of  daily maximum body temperatures of a modeled littorine snail sitting on a rock with its foot out on the rock or withdrawn into the shell. The original data are here: dailymax_runs139_169.

The code below will open the data file, create the ggplot2 figure, and save the output … Continue Reading

Digitizing data from old plots using ‘digitize’

The June 2011 issue of The R Journal contains an article on the R package digitize (link to pdf) by Timothée Poisot. This might prove to be a handy tool if you occasionally find yourself needing to retrieve data points from figures in old articles for which you don’t have the raw data. There are a number of other stand-alone software tools to accomplish this same task, such as PlotDigitizer, DataThief, or TechDig (good luck finding that last one). These other programs all work, but I use them so rarely … Continue Reading

One minor detail for getting 64-bit R-2.13 running with Eclipse/StatET

Upgrading from R-2.12 to R-2.13 was fairly painless, except for one minor hiccup in trying to get the 64-bit version running on my installation of Eclipse + StatET under Windows 7. The setup instructions are almost entirely the same as I have outlined previously (R 2.12.0 and Eclipse with StatET installation). But when you go to set up a 64-bit environment in Eclipse using those instructions, you must make one change to the Environment Configuration. Shown below is what you get when you use the “Detect Default Properties/Settings” button to find all of your R-2.13 install locations. I chose … Continue Reading

Extracting sea surface temperatures from NOAA’s OISSTv2

Update, 2015-11-30 It appears that NOAA has gone through and upgraded all of the OISST files to the newer version of the NetCDF file format. As a result, the functions outlined in this post don’t work any longer. Instead, see the updated functions in my newer post, https://lukemiller.org/index.php/2014/11/extracting-noaa-sea-surface-temperatures-with-ncdf4/. The concepts are the same as described here, but the newer functions use the ncdf4 package to access the newer NetCDF file format.

Sea surface temperatures

NOAA’s Physical Sciences Division produces a global map of weekly averaged sea … Continue Reading

RStudio – another integrated development environment for R

RStudio for Windows, Linux, and Mac OS X

If you’re in the market for a very easy-to-setup integrated development environment for R, wander over to RStudio.org. They’ve just released a beta version of their freely-available front end for R that runs under Windows, Linux and Mac OS X (for R versions 2.11 and later).

If you’re not familiar with the idea of an integrated development environment, it’s simply an attempt to bring all of the tools needed for working with R into one uniform interface. Much like the basic … Continue Reading

Converting MATLAB and R date and time values

For some unknown reason, MATLAB codes its date/time values as the number of elapsed days starting from January 1 in the year 0000. R uses the equally arbitrary, but much more widespread POSIX/Unix epoch as a reference for time keeping, so that R’s POSIX time values are stored internally as the elapsed seconds since 00:00 January 1, 1970. Converting back and forth between the two values requires just a bit of doing.

Inside R, converting from the MATLAB ‘datenum‘ value into the R POSIXt standard is fairly straightforward: Subtract 719529 from your MATLAB datenum to get the … Continue Reading