USGS - science for a changing world

sbtools - Exercises

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

# load the sbtools package
library(sbtools)

Exercise 1

Using querying functions, find out how many ScienceBase items were collected during 2010 related to lake temperature. Hint: use query_sb to search using more than one criteria, and use a Lucene query string if you want an exact match. Note: if you are not logged in, you might get a different number of results returned due to some sbitems being private.

Exercise 2

Using this item, create a new child item. Then, add a subtitle and explanation about this new child item (e.g. “this is a practice item for using sbtools”). Hint: have you authenticated?

Helpful links: item_create and item_update

Exercise 3

Using the folder “Example NWIS Data” under this item, read each file in as a data frame. Hint: JSON files can be read using fromJSON from the jsonlite package.

Helpful links: item_list_children, item_get, and item_list_files

Lindsay R. Carr