knitr::opts_chunk$set(warnings = FALSE, message = FALSE, out.width = '100%')
library(sdwisard) library(dplyr) library(ggplot2)
Make sure the package is installed. See installation instructions here.
The PSID (public water system ID number) of a water system is the only mandatory argument to get_data()
. Use the PSID of a system to get all the water quality data for that system.
For example, Alameda County Water District is PSID 0110001:
alameda_all <- get_data(psid = "0110001") glimpse(alameda_all)
sdwisard includes three helper functions:
get_water_system()
- Find PSID by county name get_analyte_summary()
- Summary about available data for a water system get_storet_id()
- Find storet id with common chemical name Supply a county to get_water_system()
to return PSIDs and water system names within that county.
get_water_system(county = "Alameda")
Supply a PSID to get_analyte_summary()
to view a summary of a water system's available analyte data.
get_analyte_summary(psid = "0110001")
Use the function get_storet_id
to search for storet IDs by common names of an analytes.
nitrate_ids <- get_storet_id("nitrate") nitrate_ids
Provide the storet ID to query for a specific analyte. The following query return all nitrate data (storet ID = A-029) for Alameda county Water District.
alameda_nitrate <- get_data(psid = "0110001", storet = "A-029")
We can plot these results with ggplot
as follows:
alameda_nitrate %>% mutate(date = as.Date(SAMP_DATE)) %>% ggplot(aes(date, FINDING)) + geom_point() + geom_smooth(se = FALSE) + labs(title = "NITRATE + NITRITE (AS N) at Alameda County Water District", y = "(MG/L)") + theme_minimal()
To query a specific date range provide a start_date
and/or end_date
argument(s) in YYYY-MM-DD format.
alameda_09_2018 <- get_data(psid = "0110001", start_date = "2018-09-01", end_date = "2018-09-30")
Full tables of metadata are also available:
water_systems
psid_analyte
analytes
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.