USGS - science for a changing world

SAWSC - North Carolina

February 7th - 9th in Raleigh, NC

Installation

See Before the Workshop for information on what software should be installed prior to the course.

Tentative schedule

Day 1

  • 08:00 am - 08:30 am – Instructors available for questions
  • 08:30 am - 10:00 am – Introduction
  • 10:00 am - 10:15 am – Break
  • 10:15 am - 12:00 pm – Get
  • 12:00 am - 01:00 pm – Lunch
  • 01:00 pm - 03:00 pm – Clean
  • 03:00 pm - 03:15 pm – Break
  • 03:15 pm - 04:15 pm – More Clean
  • 04:15 pm - 04:30 pm – End of day wrap-up

Day 2

  • 08:00 am - 08:30 am – Instructors available for questions
  • 08:30 am - 10:15 am – Explore
  • 10:15 am - 10:30 am – Break
  • 10:30 am - 12:00 pm – Analyze: Base
  • 12:00 pm - 01:00 pm – Lunch
  • 01:00 pm - 02:30 pm – Analyze: EGRET, dataRetrieval
  • 02:30 pm - 02:45 pm – Break
  • 02:45 pm - 04:15 pm – Visualize with base R: Visualize
  • 04:15 pm - 04:30 pm – End of day wrap-up

Day 3

  • 08:00 am - 08:30 am – Instructors available for questions
  • 08:30 am - 10:00 am – Repeat
  • 10:00 am - 12:00 pm – Practice: USGS R packages, projects (group/individual), or additional topics

Data files

Download data from the Data page.

Additional resources

Instructors

Lindsay Carr (lcarr@usgs.gov) – primary contact

David Watkins (wwatkins@usgs.gov)

Andrew Yan (ayan@usgs.gov)

Lesson scripts

This zip file contains the project folder and .Rproj file with the scripts that the instructors created in the class.

smwrQW

smwrQW is a package used for analyzing censored water quality data. It does not currently have a named maintainer, but there are community efforts to address questions and fix bugs on smwrQW’s GitHub page in a timely fashion. The package will remain available for use on GitHub and GRAN.

The first thing to know about smwrQW is that all functions operate on objects of class “qw”, which is a class specific to this package. For instance, it has special import functions for NWIS that use the dataRetrieval functions but return columns in a data.frame as “qw” objects instead of numeric. However, if the column does not have any censored values, the smwrQW functions will return them as normal numeric columns.

library(dataRetrieval)
library(smwrQW)

# censored values present, so importNWISqw returns a qw object
ammoniadata <- readNWISqw(siteNumbers="05330000", parameterCd="00608", endDate="2017-01-01")
class(ammoniadata$result_va)
## [1] "numeric"
ammoniadata_smwr <- importNWISqw(sites="05330000", params="00608", end.date="2017-01-01")
class(ammoniadata_smwr$Ammonia.N)
## [1] "qw"
## attr(,"package")
## [1] "smwrQW"
# no censored values present, so importNWISqw returns a numeric column
tempdata <- readNWISqw(siteNumbers="05330000", parameterCd="00010", endDate="2017-01-01")
class(tempdata$result_va)
## [1] "numeric"
tempdata_smwr <- importNWISqw(sites="05330000", params="00010", end.date="2017-01-01")
class(tempdata_smwr$WaterTempDegC)
## [1] "numeric"

We are not going to go into any additional the functions here, but will look at the resources available. This package has great documentation - there are a number of vignettes that discuss specific groups of functions and their applications. Each function is also well documented and has examples. To look at the vignettes, try running browseVignettes("smwrQW") or navigate to “Packages >> smwrQW >> User guides…” in your RStudio pane.

rloadest

rloadest is the R application and extension of the FORTRAN LOADEST constituent load estimation program. Similar to smwrQW, this package does not have an official maintainer at this time. Questions and issues can be directed to the rloadest GitHub page, and will be answered by the USGS-R community as soon as possible.

The loadReg function builds a regression model using a number of built-in load estimation models, as well as user-defined models. Two additional functions take the defined load regression and return predicted concentration (predConc) and predicted load (predLoad).

There are detailed vignettes covering applications of rloadest models to censored oruncensored data, seasonal models, etc. See browseVignettes("rloadest") or navigate to “Packages >> rloadest >> User guides…” in your RStudio pane for detailed information.

Please also reference this tutorial for using EGRET and rloadest together.