2 R Packages: irTools and wqTools

2.1 What is an R package?

R code is used to run programs that perform helpful tasks on the computer, from performing statistical tests on data to saving files downloaded from the internet. So where do packages fit into these tasks? From Quick-R: “Packages are collections of R functions, data, and compiled code in a well-defined format. The directory where packages are stored is called the library. R comes with a standard set of packages. Others are available for download and installation. Once installed, they have to be loaded into the session to be used.”

2.2 Relevant packages

Wasteload relevant functions are contained in two package: wqTools & wasteloadr. Package wqTools contains a set of useful functions that are commonly used and re-used in water quality analyses (ex. converting units, loading calculations, and downloading data). wasteloadr contains the wasteload specific functions, gadgets, and applications.
These packages live on the Utah Division of Water Quality’s GitHub. GitHub is an online platform for storing, developing, and sharing a wide variety of computer languages. DWQ’s GitHub page contains a number of repositories of R code used to perform water quality assessments and explore water quality data.

2.3 Installing wqTools and wasteloadR from GitHub

To install packages from GitHub, first install the devtools package from CRAN in R. To install the devtools package, type or copy/paste the code below into the R console and hit enter. Installing a package will also install any package dependencies.

install.packages("devtools")

A window may pop up asking you to select a CRAN repository. The “0-Cloud [https]” repository will suffice.

Load the devtools library to your workspace with the library() command. This will make all of the functions within the specified package available in your R session.

library(devtools)

To install packages from GitHub, use the devtools function install_github():

install_github("utah-dwq/wqTools", upgrade='never')
install_github("utah-dwq/wasteloadr", upgrade='never')

Note:
To avoid conflicting package versions and installations, I recommend updating package dependencies separately from GitHub package installs. To update local packages, select Packages -> Update pacakges… from the R GUI menu bar or use update.packages(ask='graphics',checkBuilt=TRUE) in the console. You can then skip package dependency updates in install_github() with the argument upgrade='never' as above.

You do not need to perform the install_github() commands each time you wish to run the packages, only when when updates are desired.