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 database R package "stoichUtilities" is a set of functions to aid with tasks like filtering, pairing water samples with organism samples and merging tables. Since it is an R package you will need to have R installed. It is recommended to install RStudio (https://www.rstudio.com/) to help manage packages and provide an integrated development environment (IDE).
There are 3 options for installing the stoichUtilities package. Installing a prebuilt package contains the vignette, while a standard "Install and Restart" won't contain the vignette. Instructions for building your own package from source to get the vignette are also included.
The "stoichUtilities" has been submitted to CRAN and should be available soon to install via the R package manager.
install.packages("stoichUtilities")
Download the stoichUtilities_x.x.x.xxxx.tar.gz file.
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"
There are 2 options to get the source files:
Navigate to the source code location and open stoichUtilities\stoichUtilities.Rproj in RStudio.
Build the documentation: ctrl + shift + D or with the menu Build -> Document
Install the library and restart the R session: ctrl + shift + B or with the menu Build -> Install and Restart
Navigate to the source code location and open stoichUtilities\stoichUtilities.Rproj in RStudio.
Select the menu option Build -> Build Source Package
To install the package, follow instructions for Installing a PreBuilt Package.
The stoichUtilities uses several other packages. Install the required packages.
install.packages(“tidyverse”)
install.packages(“lubridate”)
install.packages(“sf”)
install.packages(“units”)
Additional examples are available at Examples.pdf.
# Tidyverse and other support libraries
library(tidyverse)
library(lubridate)
library(sf)
library(units)
# Load stoichUtilities
library(stoichUtilities)
# Create a variable to store the user's home directory
basePath <- path.expand("~")
# Load the STOICH data (assumed to be in a directory named "data" inside the home directory)
stoichData <- stoichUtilities::loadSTOICH(dataPath=file.path(basePath, "data"))
# Filter the STOICH data
stoichFiltered <- stoichUtilities::filterSTOICH(dataTables=stoichData, var="State", val="FL", 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)
You can access documentation for any function using the help command.
help(loadSTOICH)