4 Using R

The neotoma2 R package provides a set of functions to download and work with data from Neotoma within the R programming environment. The package has been designed for users who wish to work with multiple sites or datasets, and supports users who wish to add their own data into Neotoma.

The functions in the R package act as wrappers for the API calls, and also provide some secondary services to help the data work efficiently in the R environment. For example, a user who wishes to search for all sites named ‘Marion Lake’ using R simply uses the get_sites() function:

library(neotoma2)
## 
## Attaching package: 'neotoma2'
## The following object is masked from 'package:dm':
## 
##     filter
## The following object is masked from 'package:jsonlite':
## 
##     toJSON
## The following object is masked from 'package:stats':
## 
##     filter
marion <- get_sites(sitename = "Marion Lake")
marion
##  siteid    sitename      lat      long altitude
##    1649 Marion Lake 49.30833 -122.5472      299
##   13416 Marion Lake 44.55609 -121.8648     1260

The following sections will detail several workflows using the R package. To help the end user we have created an instance of RStudio that is available from the browser, with all packages installed. You can access this version of RStudio from the myBinder link:

Binder

While many of our examples are drawn directly from existing workshop materials, you may find more complete details about using the R package on the GitHub page for the package, or in one or more of our posted workshops:

Other workshop materials are available within the Neotoma Workshops GitHub repository. Some workshops are highly specialized, and some contain links to cloud-based versions of RStudio so that users can work on the problems and workflows under standardized conditions.