Ecological Stoichiometry Cooperative
Return to the STOICH Database Home
The STOICH-utilities R package provides user tools for working with STOICH database files. This package is designed to enable easier and more robust access to the data files from STOICH database releases.
The STOICH API "stoichUtilities" is an R library, as such you will need to have R installed (Download R). It is recommended to install RStudio (RStudio Desktop) to help manage packages and provide an integrated development environment (IDE).
You can also download R, RStudio and the STOICH-utilities from Google Drive
The stoichUtilities uses several other packages. Install the required packages.
install.packages("tidyverse")
install.packages("lubridate")
install.packages("sf")
install.packages("units")
To run the examples you will also need to install some additional packages.
install.packages("leaflet")
install.packages("maps")
install.packages("gganimate")
install.packages("summarytools")
install.packages("DataExplorer")
Another useful package for exploring a dataset is summarytools which can be installed with install.packages("summarytools")
.
Download (source package) the stoichUtilities_0.9.x.tar.gz file.
Open RStudio
Select the menu option Tools -> Install Packages
A window should pop up. For Install from: choose Package Archive File and navigate to the location of the tar.gz file.
Click "Install"
Download the data, extract it on your computer and make a note of the path. You will have to provide the path to the loadSTOICH function.
# Tidyverse and other support libraries
library(tidyverse)
library(lubridate)
library(sf)
library(units)
# Load stoichUtilities
library(stoichUtilities)
# Three options for creating a variable to store the path to the STOICH data.
# Building the path starting at your Documents directory.
basePath <- file.path(path.expand("~"), "data", "STOICH_Beta_Release_2023-07-21")
# Or with a text string.
basePath <- "C:/Users/peter/Documents/data/STOICH_Beta_Release_2023-07-21"
# Or if you set the working directory to point to the data.
basePath <- getwd()
# Load the STOICH data (using a predefined path variable)
stoichData <- stoichUtilities::loadSTOICH(dataPath=basePath)
# Filter the STOICH data
stoichFiltered <- stoichUtilities::filterSTOICH(dataTables=stoichData, var="State", val="Florida", condition="Equal")
# Match organism stoichiometry data with water chemsitry data for samples that weren't taken at the exact same time
stoichPaired <- stoichUtilities::locateDataPairsSTOICH(stoichData, timeDiff=2, timeUnits="weeks", distance=5, pairMethod="Min Time", ignoreExisting=TRUE)
# Join all the tables into one large wide table
stoichTable <- stoichUtilities::joinSTOICH(stoichPaired)
Please visit STOICH-utilties Examples for example code.
You can access documentation for any function using the help command.
help(loadSTOICH)
To help understand the structure of data in the STOICH Database we have a couple graphics to show how the data is structured between the different tables. The general data structure consists of 5 main tables, one for each hexagon.
How each off the tables are linked and names of the variables for each table can be seen from the detailed STOICH Database diagram.