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

Interfacing XTide and R

Edit: There is now a full-fledged R package, rtide, to accomplish the same basic task of generating time series of tide predictions that is outlined here. See this more recent post for information.

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 to the minute), as well as producing sunrise and sunset times, moon phases, and times when the tide level … Continue Reading

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

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 substantially improved layout that makes the book far more useful as a general reference. This is important, since the book is meant as an accessible reference for non-statisticians to many of the powerful data manipulation and statistical techniques available in R, particularly for biologists and researchers in similar fields. With this new edition you’re no … Continue Reading

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

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 data for periods of time, so I have to break up the polygons that go with the plotted data. I could swear I wrote a function to do this several months ago, but it’s lost in a pile of other scripts, so I re-wrote a … Continue Reading

The new definitive guide for setting up Eclipse, StatET, and R on Windows 7

Quite a while back I wrote some tutorials on getting the StatET plugin for Eclipse running, so that you can write R code and run it within the Eclipse development environment. The developers of all of these pieces of software have kept marching on with the development process, so my walk-throughs are getting a little stale. Luckily, Catherine Dalzell has stepped in with an updated tutorial for getting the most recent versions up and running on Windows 7. See her blog post and the full-fledged pdf … Continue Reading

Adding p values and R squared values to a plot using expression()

I was fooling around with including a p-value and R2 value on a plot I was putting together, and found myself quickly descending into the world of R graphics esoterica. I wanted to be able to include the values on the fly using values extracted from a linear model summary object, and I wanted to use the proper italics and superscripts for the text. The desired output is shown below. What follows is how I finally generated the plot.

The goal, include the p-value and adjusted R-squared … Continue Reading

Another R + iButton script

Previously I’ve detailed R scripts that automate the launching and downloading Maxim iButton thermochron data loggers. I’m typically doing the launching and downloading at separate times in my workflow, since I have duplicate iButtons to swap out, so separate scripts work for me. Ryan Knowles recently contributed a combined version of these scripts that downloads and immediately re-launches each iButton. This is useful if you want to retrieve iButtons and then stick the same units back out in the field as soon as possible. As usual, … Continue Reading

R scripts for downloading iButton Thermochron dataloggers

Last time, I posted some R code to help quickly launch many iButton Thermochron temperature dataloggers with the same mission parameters. The R code makes use of a publicly-available command line utility released by the iButton’s manufacturer, Maxim.  Of course, Maxim also has a command line utility for downloading the data from those iButtons that you launched already. The code below will make use of that program to download an iButton, give the file a unique name of your choosing, parse the data out into a simple comma-separated-value file (for easy opening in R or Excel), and then … Continue Reading

Launching iButton Thermochrons with the help of R

Maxim’s DS1921G iButton Thermochron temperature dataloggers are little silver doo-dads the size of a large watch battery that can record up to 2048 time-stamped temperature values. The internal battery is usually good for a few years of use. Maxim supplies a Java-based application for talking to iButtons to start recording or to download results. This program, coupled with a USB-based iButton adapter, works fine when you’re just dealing with a few iButtons. But I have more than a few iButtons, so I used R to write a script to launch multiple iButtons quickly.

Continue Reading

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

Page 2 of 41234