USGS - science for a changing world

dataRetrieval - Exercises

Before starting the exercises, you should make sure that the dataRetrieval package is installed and loaded. If you haven’t recently updated, you could reinstall the package by running install.packages('dataRetrieval') or go to the “Update” button in the “Packages” tab in RStudio.

# load the dataRetrieval package
library(dataRetrieval)

# and dplyr so we can easily clean up the returned data
library(dplyr)

Exercise 1

Determine the number of sites in Arizona that have lake temperature data available in NWIS. Then find how many Arizona sites have lake temperature data available in WQP.

Helpful links: whatNWISdata, whatWQPsites, readWQPdata

Exercise 2

Determine which NWIS sites in the District of Columbia had daily streamflow below the historic daily average on August 20th, 2013. Hint: use four different functions to figure this out (find appropriate parameter code, then find site numbers, then statistics data, and then daily value data).

Helpful links: parameterCdFile, whatNWISdata, readNWISdv, renameNWISColumns, readNWISstat

Exercise 3

Find which WQP Minnesota lake sites had the maximum phosphorus level across all MN lakes measured in January 1992. Hint: use “Phosphorus” as the characteristic name.

Helpful links: readWQPdata

Exercise 4

Map the Minnesota lake phosphorus sites using your data from Exercise 3. Hint: look at metadata and consider using the maps package.

Helpful links: attributes

Lindsay R. Carr