Title: | Hydrologic AnalySis Package |
---|---|
Description: | Data aggregation and plotting of USGS groundwater level data. |
Authors: | Laura DeCicco [aut, cre] , Scott Prinos [aut] , Patrick Eslick-Huff [aut] , Candice Hopkins [aut] , Lindsay Platt [ctr], Tara Root [ctr] |
Maintainer: | Laura DeCicco <[email protected]> |
License: | CC0 |
Version: | 1.0.3 |
Built: | 2024-11-22 05:09:06 UTC |
Source: | https://code.usgs.gov/water/stats/HASP |
Example data representing Basin and Range basin-fill aquifers (N100BSNRGB).
head(aquifer_data)
head(aquifer_data)
Create composite data
composite_data(x, num_years, parameter_cd)
composite_data(x, num_years, parameter_cd)
x |
aquifer data |
num_years |
integer number of years required |
parameter_cd |
character, 5-digit parameter code, default is "72019". |
data frame with year, name, and value
aquifer_data <- aquifer_data num_years <- 30 comp_data <- composite_data(aquifer_data, num_years, "72019")
aquifer_data <- aquifer_data num_years <- 30 comp_data <- composite_data(aquifer_data, num_years, "72019")
Opens a template of the blanks sample report. Running the function will create a Rmd file. The file can be "knit" as-is, or adjusted before rendering.
create_groundwater_report( siteID, report_name, report_folder, output_type = "word" )
create_groundwater_report( siteID, report_name, report_folder, output_type = "word" )
siteID |
character. USGS site ID, should be a groundwater site. |
report_name |
character. Base name of report. |
report_folder |
character. Report folder, can be full path or partial. |
output_type |
should be either "word", "html", or "pdf". |
## Not run: create_groundwater_report("424520070562401", report_name = "example_report", report_folder = "reports", output_type = "word") create_groundwater_report("424520070562401", report_name = "example_report", report_folder = "reports", output_type = "html") ## End(Not run)
## Not run: create_groundwater_report("424520070562401", report_name = "example_report", report_folder = "reports", output_type = "word") create_groundwater_report("424520070562401", report_name = "example_report", report_folder = "reports", output_type = "html") ## End(Not run)
Calculates the historical max, mean, minimum, and number of available points for each day of the year
daily_frequency_table( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA )
daily_frequency_table( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA )
gw_level_dv |
data frame, daily groundwater level data
from |
gwl_data |
data frame returned from dataRetrieval::readNWISgwl, or data frame with mandatory columns lev_dt (representing date), lev_age_cd (representing approval code), and a column representing the measured value (either lev_va, sl_lev_va, or value). |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col.
If the data doesn't come directly from NWIS services, this
can be set to |
date_col |
the heading of the date column. The default is |
value_col |
name of value column. The default is |
approved_col |
name of column to get provisional/approved status. |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
a data frame giving the max, mean, min, and number of available days of data for each day of the year.
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily daily_frequency_table(gw_level_dv, NULL, parameter_cd = "62610") gwl_data <- L2701_example_data$Discrete daily_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610")
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily daily_frequency_table(gw_level_dv, NULL, parameter_cd = "62610") gwl_data <- L2701_example_data$Discrete daily_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610")
Calculates daily statistics based on all approved data. Daily, discrete, or both types are included. Historic median or mean are plotted based on all of the approved data.
daily_gwl_plot( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, start_date = NA, end_date = NA, historical_stat = "mean", month_breaks = FALSE, plot_title = "", subtitle = "U.S. Geological Survey", y_axis_label = "", flip = FALSE )
daily_gwl_plot( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, start_date = NA, end_date = NA, historical_stat = "mean", month_breaks = FALSE, plot_title = "", subtitle = "U.S. Geological Survey", y_axis_label = "", flip = FALSE )
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
gwl_data |
data frame returned from |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
start_date |
Date to start plot. If |
end_date |
Date to end plot. If |
historical_stat |
the summary statistic to use for middle line of the plot. Either "mean" or "median." |
month_breaks |
a logical indicating whether to use monthly breaks for the plot |
plot_title |
the title to use on the plot |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
y_axis_label |
the label to use for the y axis |
flip |
logical. If |
a ggplot object with a ribbon indicating the historical daily range, the historical daily mean or median, and approved and provisional daily data for the last two years
site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily gwl_data <- L2701_example_data$Discrete daily_gwl_plot(gw_level_dv, NULL, parameter_cd = "62610", plot_title = "Groundwater Level", historical_stat = "median") daily_gwl_plot(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = "Groundwater Level", historical_stat = "median") daily_gwl_plot(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = "Groundwater Level", month_breaks = TRUE, start_date = "2020-10-01", historical_stat = "median") daily_gwl_plot(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = "Groundwater Level", month_breaks = TRUE, start_date = "2018-10-01", end_date = "2020-10-01", historical_stat = "median")
site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily gwl_data <- L2701_example_data$Discrete daily_gwl_plot(gw_level_dv, NULL, parameter_cd = "62610", plot_title = "Groundwater Level", historical_stat = "median") daily_gwl_plot(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = "Groundwater Level", historical_stat = "median") daily_gwl_plot(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = "Groundwater Level", month_breaks = TRUE, start_date = "2020-10-01", historical_stat = "median") daily_gwl_plot(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = "Groundwater Level", month_breaks = TRUE, start_date = "2018-10-01", end_date = "2020-10-01", historical_stat = "median")
Summary table of daily data
daily_gwl_summary( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA )
daily_gwl_summary( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA )
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
gwl_data |
data frame returned from |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
a summary table giving the period of record, completeness and percentile values
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily daily_gwl_summary(gw_level_dv, gwl_data = NULL, parameter_cd = p_code_dv) gwl_data <- L2701_example_data$Discrete daily_gwl_summary(gw_level_dv, gwl_data = gwl_data, parameter_cd = p_code_dv)
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily daily_gwl_summary(gw_level_dv, gwl_data = NULL, parameter_cd = p_code_dv) gwl_data <- L2701_example_data$Discrete daily_gwl_summary(gw_level_dv, gwl_data = gwl_data, parameter_cd = p_code_dv)
Get station summary information
data_available(siteID)
data_available(siteID)
siteID |
character. USGS site ID for a groundwater site. |
siteID <- "263819081585801" site_data_available <- data_available(siteID)
siteID <- "263819081585801" site_data_available <- data_available(siteID)
Open an interactive app in a browser. See the "Shiny App" vignette:
vignette("shinyApp", package = "toxEval")
for more details. Using this
function is a quick and convenient way
to explore data. For more customization, the R-code to
produce each graph and table is displayed in the app. That is
a good starting-point for a custom analysis.
explore_aquifers(browse = TRUE) explore_site(browse = TRUE)
explore_aquifers(browse = TRUE) explore_site(browse = TRUE)
browse |
Logical. Use browser for running Shiny app. |
## Not run: explore_aquifers() ## End(Not run) ## Not run: explore_site() ## End(Not run)
## Not run: explore_aquifers() ## End(Not run) ## Not run: explore_site() ## End(Not run)
Filter down to sites with num_years of data
filter_sites( x, parameter_cd = "72019", num_years = NA, start_year = NA, end_year = NA )
filter_sites( x, parameter_cd = "72019", num_years = NA, start_year = NA, end_year = NA )
x |
aquifer data |
parameter_cd |
character, 5-digit parameter code, default is "72019". |
num_years |
integer number of years required. This can be
|
start_year |
integer the first year to filter from. If |
end_year |
integer the last year to filter from. If |
data frame filter of x
aquifer_data <- aquifer_data num_years <- 30 aq_data <- filter_sites(aquifer_data, parameter_cd = "72019", num_years = num_years)
aquifer_data <- aquifer_data num_years <- 30 aq_data <- filter_sites(aquifer_data, parameter_cd = "72019", num_years = num_years)
Find the first day of the month for a given date
first_day(date)
first_day(date)
date |
a vector of dates |
the first day of the month that given dates fall in
date <- as.Date("2020-12-28") first_day(date)
date <- as.Date("2020-12-28") first_day(date)
Get USGS data based on aquiferCd
get_aquifer_data(aquiferCd, startDate, endDate, parameter_cd = "72019")
get_aquifer_data(aquiferCd, startDate, endDate, parameter_cd = "72019")
aquiferCd |
character. To see valid aquifer codes, see the included data
frame |
startDate |
date or string. Beginning date of when to pull data. |
endDate |
date of string Ending date to pull data. |
parameter_cd |
5-digit character USGS parameter code. |
end_date <- "2021-01-01" start_date <- "1989-12-31" aquiferCd <- "S100CSLLWD" aq_data <- get_aquifer_data(aquiferCd, start_date, end_date)
end_date <- "2021-01-01" start_date <- "1989-12-31" aquiferCd <- "S100CSLLWD" aq_data <- get_aquifer_data(aquiferCd, start_date, end_date)
Get USGS data based for a single state with specific aquifer codes.
get_state_data(state, aquiferCd, startDate, endDate, parameter_cd = "72019")
get_state_data(state, aquiferCd, startDate, endDate, parameter_cd = "72019")
state |
character. Can be state abbreviation, long name, or numeric code. |
aquiferCd |
character. To see valid aquifer codes, see the included data
frame |
startDate |
date or string. Beginning date of when to pull data. |
endDate |
date of string Ending date to pull data. |
parameter_cd |
5-digit character USGS parameter code. Default is "72019". |
end_date <- "2021-01-01" start_date <- "1989-12-31" aquiferCd <- "S100CSLLWD" st_data <- get_state_data("WI", aquiferCd, start_date, end_date)
end_date <- "2021-01-01" start_date <- "1989-12-31" aquiferCd <- "S100CSLLWD" st_data <- get_state_data("WI", aquiferCd, start_date, end_date)
Function to create the field groundwater level data plot.
gwl_plot_field( gwl_data, plot_title = "", parameter_cd = NA, date_col = "lev_dt", value_col = NA, approved_col = "lev_age_cd", flip = TRUE, y_label = "", subtitle = "U.S. Geological Survey" ) gwl_plot_all( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, y_label = "", subtitle = "U.S. Geological Survey", plot_title = "", add_trend = FALSE, n_years = 10, POR_trend = TRUE, flip = FALSE, days_required_per_month = 14 )
gwl_plot_field( gwl_data, plot_title = "", parameter_cd = NA, date_col = "lev_dt", value_col = NA, approved_col = "lev_age_cd", flip = TRUE, y_label = "", subtitle = "U.S. Geological Survey" ) gwl_plot_all( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, y_label = "", subtitle = "U.S. Geological Survey", plot_title = "", add_trend = FALSE, n_years = 10, POR_trend = TRUE, flip = FALSE, days_required_per_month = 14 )
gwl_data |
data frame returned from |
plot_title |
character, title for plot. |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
flip |
logical. If |
y_label |
character for y-axis label. Consider using |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
add_trend |
logical. Uses |
n_years |
integer. This is the number of years to calculate the trend on. Default is 10. This can be a vector of years. |
POR_trend |
a logical indicating whether to include a trend test
for the full period of record. Default is |
days_required_per_month |
integer. Number of days required per month.
Default is 14. Only used if add_trend is |
# site <- "263819081585801" # gwl_data <- dataRetrieval::readNWISgwl(site) # Using package example data: gwl_data <- L2701_example_data$Discrete plot_title <- attr(gwl_data, "siteInfo")[["station_nm"]] pcodes <- dataRetrieval::readNWISpCode(unique(gwl_data$parameter_cd)) gwl_plot_field(gwl_data, plot_title = plot_title, parameter_cd = "62610", flip = FALSE, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"]) gwl_plot_field(gwl_data, plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62611"], parameter_cd = "62611", flip = FALSE) gwl_plot_field(gwl_data, plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "72019"], parameter_cd = "72019", flip = TRUE) # site <- "263819081585801" parameterCd <- "62610" # statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, parameterCd, statCd = statCd) # Using package example data: gw_level_dv <- L2701_example_data$Daily gwl_data <- L2701_example_data$Discrete plot_title <- attr(gwl_data, "siteInfo")[["station_nm"]] pcodes <- dataRetrieval::readNWISpCode(unique(gwl_data$parameter_cd)) gwl_plot_all(gw_level_dv, NULL, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], flip = TRUE) gwl_plot_all(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], add_trend = TRUE, flip = FALSE) gwl_plot_all(gw_level_dv, gwl_data, parameter_cd = "62610", n_years = c(5, 10, 20), POR_trend = TRUE, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], plot_title = plot_title, add_trend = TRUE) gwl_plot_all(NULL, gwl_data, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"]) gwl_plot_all(NULL, gwl_data, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], add_trend = TRUE)
# site <- "263819081585801" # gwl_data <- dataRetrieval::readNWISgwl(site) # Using package example data: gwl_data <- L2701_example_data$Discrete plot_title <- attr(gwl_data, "siteInfo")[["station_nm"]] pcodes <- dataRetrieval::readNWISpCode(unique(gwl_data$parameter_cd)) gwl_plot_field(gwl_data, plot_title = plot_title, parameter_cd = "62610", flip = FALSE, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"]) gwl_plot_field(gwl_data, plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62611"], parameter_cd = "62611", flip = FALSE) gwl_plot_field(gwl_data, plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "72019"], parameter_cd = "72019", flip = TRUE) # site <- "263819081585801" parameterCd <- "62610" # statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, parameterCd, statCd = statCd) # Using package example data: gw_level_dv <- L2701_example_data$Daily gwl_data <- L2701_example_data$Discrete plot_title <- attr(gwl_data, "siteInfo")[["station_nm"]] pcodes <- dataRetrieval::readNWISpCode(unique(gwl_data$parameter_cd)) gwl_plot_all(gw_level_dv, NULL, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], flip = TRUE) gwl_plot_all(gw_level_dv, gwl_data, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], add_trend = TRUE, flip = FALSE) gwl_plot_all(gw_level_dv, gwl_data, parameter_cd = "62610", n_years = c(5, 10, 20), POR_trend = TRUE, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], plot_title = plot_title, add_trend = TRUE) gwl_plot_all(NULL, gwl_data, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"]) gwl_plot_all(NULL, gwl_data, parameter_cd = "62610", plot_title = plot_title, y_label = pcodes$parameter_nm[pcodes$parameter_cd == "62610"], add_trend = TRUE)
Example data from site 263819081585801 L-2701. Data is a named list of "Daily" for daily groundwater level at the site and "Discrete" for discrete groundwater level measurements from the site. Updated April 9, 2021.
head(L2701_example_data$Daily) head(L2701_example_data$Discrete) head(L2701_example_data$QW)
head(L2701_example_data$Daily) head(L2701_example_data$Discrete) head(L2701_example_data$QW)
Find the last day of the month for a given date
last_day(date)
last_day(date)
date |
a vector of dates |
the last day of the month that given dates fall in
date <- as.Date("2020-12-28") last_day(date) last_day("2020-02-15") last_day("2019-02-15") last_day(c("2020-12-28", "2020-02-15", "2019-02-15"))
date <- as.Date("2020-12-28") last_day(date) last_day("2020-02-15") last_day("2019-02-15") last_day(c("2020-12-28", "2020-02-15", "2019-02-15"))
Map data used in composite hydrographs
map_hydro_data(x, num_years, parameter_cd = "72019")
map_hydro_data(x, num_years, parameter_cd = "72019")
x |
aquifer data frame. Requires at least 3 columns. Two are required "site_no", "year", and "value". |
num_years |
integer number of years required |
parameter_cd |
character, 5-digit parameter code, default is "72019". |
leaflet object
aquifer_data <- aquifer_data num_years <- 30 map_data <- map_hydro_data(aquifer_data, num_years) map_data
aquifer_data <- aquifer_data num_years <- 30 map_data <- map_hydro_data(aquifer_data, num_years) map_data
Find the middle of the month for a given date
mid_month(date)
mid_month(date)
date |
a vector of dates |
the middle day of the month the given dates fall in
date <- as.Date("2020-12-28") mid_month(date) mid_month(c("2019-02-15", "2020-03-08", "2010-06-01"))
date <- as.Date("2020-12-28") mid_month(date) mid_month(c("2019-02-15", "2020-03-08", "2010-06-01"))
This plot uses calculations from monthly_frequency_table
. Daily, discrete,
or both types of data can be included.
monthly_frequency_plot( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, plot_title = "", subtitle = "U.S. Geological Survey", plot_range = c("Past year"), y_axis_label = "", flip = FALSE, percentile_colors = NA, include_edges = FALSE, median_point_size = 2.5, data_point_size = 2.5 )
monthly_frequency_plot( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, plot_title = "", subtitle = "U.S. Geological Survey", plot_range = c("Past year"), y_axis_label = "", flip = FALSE, percentile_colors = NA, include_edges = FALSE, median_point_size = 2.5, data_point_size = 2.5 )
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
gwl_data |
data frame returned from |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
plot_title |
the title to use on the plot. |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
plot_range |
the time frame to use for the plot. Either "Past year" to use the last year of data, or "Calendar year" to use the current calendar year, beginning in January. |
y_axis_label |
the label used for the y-axis of the plot. |
flip |
logical. If |
percentile_colors |
Optional argument to provide a vector of 5 or 7 colors
used to fill the percentile bars in order from lowest percentile bin to the
highest percentile bin. Default behavior ( |
include_edges |
Optional argument to toggle on the "edge bins" min-5 and 95-max on the plot. Default is FALSE which does not plot those bins. |
median_point_size |
Optional argument to specify the size of the median point markers which are shown as black triangles on the plot. The default size is 2.5. |
data_point_size |
Optional argument to specify the size of the data point markers which are shown as red diamonds on the plot. The default size is 2.5. |
a ggplot with rectangles representing the historical monthly percentile, black triangles representing the historical monthly median, and red diamonds showing the last year of groundwater level measurements.
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily label <- dataRetrieval::readNWISpCode(p_code_dv)[["parameter_nm"]] monthly_frequency <- monthly_frequency_plot(gw_level_dv, gwl_data = NULL, parameter_cd = "62610", plot_title = "L2701 Groundwater Level", y_axis_label = label, flip = FALSE) monthly_frequency gwl_data <- L2701_example_data$Discrete monthly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610", plot_title = "L2701 Groundwater Level", y_axis_label = label, flip = FALSE) monthly_frequency_flip <- monthly_frequency_plot(gw_level_dv, gwl_data, parameter_cd = "62610", y_axis_label = label, plot_title = "L2701 Groundwater Level", flip = TRUE) monthly_frequency_flip monthly_frequency_custom_colors <- monthly_frequency_plot(gw_level_dv, gwl_data, parameter_cd = "62610", y_axis_label = label, plot_title = "L2701 Groundwater Level", flip = TRUE, percentile_colors = c( "red", "yellow", "green", "blue", "orange" )) monthly_frequency_custom_colors monthly_frequency_edge_bins <- monthly_frequency_plot(gw_level_dv, gwl_data, parameter_cd = "62610", y_axis_label = label, plot_title = "L2701 Groundwater Level", flip = FALSE, include_edges = TRUE) monthly_frequency_edge_bins monthly_frequency_custom_point_sizes <- monthly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610", plot_title = "L2701 Groundwater Level", y_axis_label = label, median_point_size = 0.5, data_point_size = 3) monthly_frequency_custom_point_sizes
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily label <- dataRetrieval::readNWISpCode(p_code_dv)[["parameter_nm"]] monthly_frequency <- monthly_frequency_plot(gw_level_dv, gwl_data = NULL, parameter_cd = "62610", plot_title = "L2701 Groundwater Level", y_axis_label = label, flip = FALSE) monthly_frequency gwl_data <- L2701_example_data$Discrete monthly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610", plot_title = "L2701 Groundwater Level", y_axis_label = label, flip = FALSE) monthly_frequency_flip <- monthly_frequency_plot(gw_level_dv, gwl_data, parameter_cd = "62610", y_axis_label = label, plot_title = "L2701 Groundwater Level", flip = TRUE) monthly_frequency_flip monthly_frequency_custom_colors <- monthly_frequency_plot(gw_level_dv, gwl_data, parameter_cd = "62610", y_axis_label = label, plot_title = "L2701 Groundwater Level", flip = TRUE, percentile_colors = c( "red", "yellow", "green", "blue", "orange" )) monthly_frequency_custom_colors monthly_frequency_edge_bins <- monthly_frequency_plot(gw_level_dv, gwl_data, parameter_cd = "62610", y_axis_label = label, plot_title = "L2701 Groundwater Level", flip = FALSE, include_edges = TRUE) monthly_frequency_edge_bins monthly_frequency_custom_point_sizes <- monthly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610", plot_title = "L2701 Groundwater Level", y_axis_label = label, median_point_size = 0.5, data_point_size = 3) monthly_frequency_custom_point_sizes
The table will accept daily, discrete, or a both types of data. The median of each
year/month is calculated. Then using that median, monthly stats are calculated.
Percentiles are calculated using the quantile
function with "type=6".
monthly_frequency_table( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, flip = FALSE )
monthly_frequency_table( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, flip = FALSE )
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
gwl_data |
data frame returned from |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
flip |
logical. If |
a data frame of monthly groundwater level statistics including the 5th, 10th, 25th, 75th, 90th, and 95th percentiles; the number of years of data; and the lowest monthly median and the highest monthly median.
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily monthly_frequency <- monthly_frequency_table(gw_level_dv, NULL, parameter_cd = "62610") head(monthly_frequency) gwl_data <- L2701_example_data$Discrete monthly_frequency_combo <- monthly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610") head(monthly_frequency_combo) monthly_flip <- monthly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610", flip = TRUE) head(monthly_flip)
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily monthly_frequency <- monthly_frequency_table(gw_level_dv, NULL, parameter_cd = "62610") head(monthly_frequency) gwl_data <- L2701_example_data$Discrete monthly_frequency_combo <- monthly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610") head(monthly_frequency_combo) monthly_flip <- monthly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610", flip = TRUE) head(monthly_flip)
Take the mean of each month, filter if there's not at least 15 days, and create a new date that is the midpoint of each month.
monthly_mean(x, date_col = "Date", value_col = "X_62610_00001")
monthly_mean(x, date_col = "Date", value_col = "X_62610_00001")
x |
data.frame |
date_col |
character name of date column |
value_col |
character name of value column |
# site <- "263819081585801" parameterCd <- "62610" # statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, parameterCd, # statCd = statCd) # Using package example data: gw_level_dv <- L2701_example_data$Daily site_statistics <- monthly_frequency_table(gw_level_dv, NULL, parameter_cd = parameterCd) gw_monthly <- monthly_mean(gw_level_dv)
# site <- "263819081585801" parameterCd <- "62610" # statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, parameterCd, # statCd = statCd) # Using package example data: gw_level_dv <- L2701_example_data$Daily site_statistics <- monthly_frequency_table(gw_level_dv, NULL, parameter_cd = parameterCd) gw_monthly <- monthly_mean(gw_level_dv)
National aquifer data
Local aquifer data codes
markerTable raw data
data frame with columns Country, State, nat_aqfr_cd, long_name, and other_cd
data frame with columns long_name, nat_aqfr_cd, state_indexes, and states
data frame with aqfr_cd, Aqfr_Name_prpr
data frame with columns Trend and MarkerDescription
data frame with columns trendType, trend, markerDescription, r_lwd
head(nat_aqfr_state) head(summary_aquifers) head(local_aqfr)
head(nat_aqfr_state) head(summary_aquifers) head(local_aqfr)
Create normalized composite data
normalized_data(x, num_years, parameter_cd = "72019")
normalized_data(x, num_years, parameter_cd = "72019")
x |
aquifer data |
num_years |
integer number of years required |
parameter_cd |
character, 5-digit parameter code, default is "72019". |
Information can be found here: https://groundwaterwatch.usgs.gov/composite/help/CompositeGroundwaterLevelHelpDocument.docx.html
data frame with year, name, and value
aquifer_data <- aquifer_data num_years <- 30 norm_data <- normalized_data(aquifer_data, num_years, "72019")
aquifer_data <- aquifer_data num_years <- 30 norm_data <- normalized_data(aquifer_data, num_years, "72019")
Create composite hydrograph plot
plot_composite_data( x, num_years = NA, parameter_cd = "72019", plot_title = "", subtitle = "U.S. Geological Survey" )
plot_composite_data( x, num_years = NA, parameter_cd = "72019", plot_title = "", subtitle = "U.S. Geological Survey" )
x |
aquifer data frame. Requires at least 3 columns. Two are required "site_no", "year", and "value". |
num_years |
integer number of years required. If |
parameter_cd |
character, 5-digit parameter code, default is "72019". |
plot_title |
character title included on plot. |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
ggplot2 object
aquifer_data <- aquifer_data comp_data <- plot_composite_data(aquifer_data, num_years = 30, parameter_cd = "72019", plot_title = "Calendar Year") comp_data # Do it on a water year: aquifer_data$cal_year <- aquifer_data$year aquifer_data$year <- aquifer_data$water_year plot_composite_data(aquifer_data, parameter_cd = "72019", num_years = 30, plot_title = "Water Year")
aquifer_data <- aquifer_data comp_data <- plot_composite_data(aquifer_data, num_years = 30, parameter_cd = "72019", plot_title = "Calendar Year") comp_data # Do it on a water year: aquifer_data$cal_year <- aquifer_data$year aquifer_data$year <- aquifer_data$water_year plot_composite_data(aquifer_data, parameter_cd = "72019", num_years = 30, plot_title = "Water Year")
Create composite hydrograph plot
plot_normalized_data( x, num_years = NA, parameter_cd = "72019", plot_title = "", subtitle = "U.S. Geological Survey" )
plot_normalized_data( x, num_years = NA, parameter_cd = "72019", plot_title = "", subtitle = "U.S. Geological Survey" )
x |
aquifer data frame. Requires at least 3 columns. Two are required "site_no", "year", and "value". |
num_years |
integer number of years required to the analysis. If |
parameter_cd |
character, 5-digit parameter code, default is "72019". |
plot_title |
character title of plot. |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
ggplot2 object
aquifer_data <- aquifer_data norm_data <- plot_normalized_data(aquifer_data, parameter_cd = "72019", num_years = 30) norm_data aquifer_data$cal_year <- aquifer_data$year aquifer_data$year <- aquifer_data$water_year plot_normalized_data(aquifer_data, parameter_cd = "72019", num_years = 30)
aquifer_data <- aquifer_data norm_data <- plot_normalized_data(aquifer_data, parameter_cd = "72019", num_years = 30) norm_data aquifer_data$cal_year <- aquifer_data$year aquifer_data$year <- aquifer_data$water_year plot_normalized_data(aquifer_data, parameter_cd = "72019", num_years = 30)
Functions to create the individual chloride, specific conductance, and combination plots and tables for a single site.
Sc_Cl_plot(qw_data, plot_title, subtitle = "U.S. Geological Survey") Sc_Cl_table(qw_data) qw_plot( qw_data, plot_title, y_label = NA, CharacteristicName = "Chloride", start_date = NA, end_date = NA, subtitle = "U.S. Geological Survey" ) qw_summary(qw_data, CharacteristicName, norm_range = NA)
Sc_Cl_plot(qw_data, plot_title, subtitle = "U.S. Geological Survey") Sc_Cl_table(qw_data) qw_plot( qw_data, plot_title, y_label = NA, CharacteristicName = "Chloride", start_date = NA, end_date = NA, subtitle = "U.S. Geological Survey" ) qw_summary(qw_data, CharacteristicName, norm_range = NA)
qw_data |
data frame returned from dataRetrieval::readWQPqw, must include columns sample_dt, parm_cd, result_va |
plot_title |
character title for plot |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
y_label |
character label for y axis. If left as NA, the function will attempt to use the "variableInfo" attribute of qw_data. This is attached to dataRetrieval output. |
CharacteristicName |
character CharacteristicName to filter to. |
start_date |
Date to start plot. If |
end_date |
Date to end plot. If |
norm_range |
a numerical range to potentially group the data. If NA, no grouping is shown. |
# site <- "263819081585801" # parameterCd <- c("00095","90095","00940","99220") # site_data <- dataRetrieval::readWQPqw(site, # parameterCd) # Using package example data: qw_data <- L2701_example_data$QW plot_title <- paste(attr(qw_data, "siteInfo")[["station_nm"]], ": Specific Conductance vs Chloride") Sc_Cl_plot(qw_data, plot_title) sc_cl <- Sc_Cl_table(qw_data) plot_title <- attr(qw_data, "siteInfo")[["station_nm"]] qw_plot(qw_data, plot_title, CharacteristicName = "Chloride") qw_plot(qw_data, plot_title, CharacteristicName = "Specific conductance") qw_plot(qw_data, plot_title, CharacteristicName = "Specific conductance", start_date = "1990-01-01") site <- "USGS-01491000" qw_data_phos <- dataRetrieval::readWQPqw(site, "Orthophosphate") qw_plot(qw_data_phos , CharacteristicName = "Orthophosphate", plot_title = "Choptank: Orthophosphate") qw_summary(qw_data, CharacteristicName = "Chloride", norm_range = c(230, 860)) qw_summary(qw_data, CharacteristicName = "Specific conductance", norm_range = NA)
# site <- "263819081585801" # parameterCd <- c("00095","90095","00940","99220") # site_data <- dataRetrieval::readWQPqw(site, # parameterCd) # Using package example data: qw_data <- L2701_example_data$QW plot_title <- paste(attr(qw_data, "siteInfo")[["station_nm"]], ": Specific Conductance vs Chloride") Sc_Cl_plot(qw_data, plot_title) sc_cl <- Sc_Cl_table(qw_data) plot_title <- attr(qw_data, "siteInfo")[["station_nm"]] qw_plot(qw_data, plot_title, CharacteristicName = "Chloride") qw_plot(qw_data, plot_title, CharacteristicName = "Specific conductance") qw_plot(qw_data, plot_title, CharacteristicName = "Specific conductance", start_date = "1990-01-01") site <- "USGS-01491000" qw_data_phos <- dataRetrieval::readWQPqw(site, "Orthophosphate") qw_plot(qw_data_phos , CharacteristicName = "Orthophosphate", plot_title = "Choptank: Orthophosphate") qw_summary(qw_data, CharacteristicName = "Chloride", norm_range = c(230, 860)) qw_summary(qw_data, CharacteristicName = "Specific conductance", norm_range = NA)
Get summaries of data by site. Requires a column site_no, and will take the summaries
site_data_summary(x, value_col = "value", site_col = "site_no")
site_data_summary(x, value_col = "value", site_col = "site_no")
x |
data frame |
value_col |
name of value column. The default is |
site_col |
name of site column. This is the column we are grouping by. |
data frame with 10 columns
aquifer_data <- aquifer_data aquifer_data <- aquifer_data[aquifer_data$parameter_cd == "72019", ] summary_info <- site_data_summary(aquifer_data)
aquifer_data <- aquifer_data aquifer_data <- aquifer_data[aquifer_data$parameter_cd == "72019", ] summary_info <- site_data_summary(aquifer_data)
Get station summary information
site_summary(siteID, markdown = FALSE)
site_summary(siteID, markdown = FALSE)
siteID |
character |
markdown |
logical. Use markdown formating or console-friendly. |
siteID <- "263819081585801" site_metadata <- site_summary(siteID)
siteID <- "263819081585801" site_metadata <- site_summary(siteID)
Themes and other useful graphing utilities for the HASP package
theme_gwl(base_family = "", ...) hasp_framework( x_label, y_label, plot_title, include_y_scale = FALSE, zero_on_top = TRUE, subtitle = "U.S. Geological Survey" )
theme_gwl(base_family = "", ...) hasp_framework( x_label, y_label, plot_title, include_y_scale = FALSE, zero_on_top = TRUE, subtitle = "U.S. Geological Survey" )
base_family |
character base font family |
... |
additional arguments |
x_label |
character. Label for x-axis. |
y_label |
character. Label for y-axis. |
plot_title |
character. Title for plot. |
include_y_scale |
logical. If |
zero_on_top |
logical. If zero_on_top is |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
ggplot2::ggplot() + theme_gwl() x_label <- "Date" y_label <- "Level" plot_title <- "Super Site" ggplot2::ggplot() + hasp_framework(x_label, y_label, plot_title)
ggplot2::ggplot() + theme_gwl() x_label <- "Date" y_label <- "Level" plot_title <- "Super Site" ggplot2::ggplot() + hasp_framework(x_label, y_label, plot_title)
Function creates the cloride over time plot with trends.
trend_plot( qw_data, plot_title, y_label = NA, n_years = 10, POR_trend = TRUE, CharacteristicName = c("Chloride"), norm_range = c(230, 860), subtitle = "U.S. Geological Survey", include_table = TRUE )
trend_plot( qw_data, plot_title, y_label = NA, n_years = 10, POR_trend = TRUE, CharacteristicName = c("Chloride"), norm_range = c(230, 860), subtitle = "U.S. Geological Survey", include_table = TRUE )
qw_data |
data frame returned from dataRetrieval::readWQPqw, must include columns ActivityStartDateTime, CharacteristicName, result_va |
plot_title |
character title for plot |
y_label |
character label for y axis. If left as NA, the function will attempt to use the "variableInfo" attribute of qw_data. This is attached to dataRetrieval output. |
n_years |
integer. This is the number of years to calculate the trend on. Default is 10. This can be a vector of years. |
POR_trend |
a logical indicating whether to include a trend test
for the full period of record. Default is |
CharacteristicName |
character CharacteristicName to plot |
norm_range |
a numerical range to potentially group the data. If NA, no grouping is shown. |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
include_table |
logical whether or not to include the trend table in the upper left corner. |
# site <- "263819081585801" # parameterCd <- c("00095","90095","00940","99220") # site_data <- dataRetrieval::readWQPqw(site, # parameterCd) # Using package example data: qw_data <- L2701_example_data$QW plot_title <- paste(attr(qw_data, "siteInfo")[["station_nm"]], ": Chloride") trend_plot(qw_data, plot_title)
# site <- "263819081585801" # parameterCd <- c("00095","90095","00940","99220") # site_data <- dataRetrieval::readWQPqw(site, # parameterCd) # Using package example data: qw_data <- L2701_example_data$QW plot_title <- paste(attr(qw_data, "siteInfo")[["station_nm"]], ": Chloride") trend_plot(qw_data, plot_title)
Test for period of record and user-specified ranges. The default trends are calculated for 10 year and the full period of record.
trend_test( gw_level_dv, gwl_data, n_years = 10, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, pctComplete = 0.5, days_required_per_month = 14, POR_trend = TRUE )
trend_test( gw_level_dv, gwl_data, n_years = 10, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, pctComplete = 0.5, days_required_per_month = 14, POR_trend = TRUE )
gw_level_dv |
daily groundwater level data frame. Often obtained from from |
gwl_data |
data frame returned from dataRetrieval::readNWISgwl, or data frame with mandatory columns lev_dt (representing date), lev_age_cd (representing approval code), and a column representing the measured value (either lev_va, sl_lev_va, or value). |
n_years |
integer. This is the number of years to calculate the trend on. Default is 10. This can be a vector of years. |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col.
If the data doesn't come directly from NWIS services, this
can be set to |
date_col |
the heading of the date column. The default is |
value_col |
name of value column. The default is |
approved_col |
name of column to get provisional/approved status. |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
pctComplete |
number percentage complete. This is a fraction that represents the amount of data that must be included overall in order to calculate a trend. The default is 0.5, which means if gaps in the data span more than 50 total record, a trend will not be calculated. |
days_required_per_month |
integer. Number of days required per month to include in the trend test. Default is 14. |
POR_trend |
a logical indicating whether to include a trend test
for the full period of record. Default is |
For data that is at least on a daily interval, the rkt function is used. For periodic data, the kendallTrendTest is used.
a data frame of test results from 5 and 20 year Kendall Seasonal Trend test
# site <- "263819081585801" # gw_level_data <- dataRetrieval::readNWISgwl(site) # Using package example data: gwl_data <- L2701_example_data$Discrete gw_level_dv <- L2701_example_data$Daily trend_test(gw_level_dv, gwl_data, parameter_cd = "62610") trend_test(gw_level_dv, gwl_data, POR_trend = FALSE, parameter_cd = "62610") trend_test(gw_level_dv, gwl_data, parameter_cd = "62610", n_years = 5) trend_test(gw_level_dv, gwl_data, parameter_cd = "62610", n_years = c(5, 10, 20)) # Only periodic data: trend_test(NULL, gwl_data, parameter_cd = "62610")
# site <- "263819081585801" # gw_level_data <- dataRetrieval::readNWISgwl(site) # Using package example data: gwl_data <- L2701_example_data$Discrete gw_level_dv <- L2701_example_data$Daily trend_test(gw_level_dv, gwl_data, parameter_cd = "62610") trend_test(gw_level_dv, gwl_data, POR_trend = FALSE, parameter_cd = "62610") trend_test(gw_level_dv, gwl_data, parameter_cd = "62610", n_years = 5) trend_test(gw_level_dv, gwl_data, parameter_cd = "62610", n_years = c(5, 10, 20)) # Only periodic data: trend_test(NULL, gwl_data, parameter_cd = "62610")
This function is a little more robust than calcWaterYear
water_year(x)
water_year(x)
x |
character vector |
x <- c("2010-01-01", "1994-02", "1980", "2009-11-01") water_year(x)
x <- c("2010-01-01", "1994-02", "1980", "2009-11-01") water_year(x)
Weekly statistics are calculated using the weekly_frequency_table
function.
Daily, discrete, or both types of data can be used.
weekly_frequency_plot( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, plot_range = "Past year", plot_title = "", subtitle = "U.S. Geological Survey", y_axis_label = "", flip = FALSE, percentile_colors = NA )
weekly_frequency_plot( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, plot_range = "Past year", plot_title = "", subtitle = "U.S. Geological Survey", y_axis_label = "", flip = FALSE, percentile_colors = NA )
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
gwl_data |
data frame returned from |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
plot_range |
the time frame to use for the plot. Either "Past year" to use the last year of data, or "Calendar year" to use the current calendar year, beginning in January. |
plot_title |
the title to use on the plot |
subtitle |
character. Sub-title for plot, default is "U.S. Geological Survey". |
y_axis_label |
the label used for the y-axis of the plot. |
flip |
logical. If |
percentile_colors |
Optional argument to provide a vector of 5 colors used to fill the percentile bars in order from lowest percentile bin to the highest percentile bin. Default behavior (NA) is to use legacy plot colors. |
a ggplot object with rectangles representing the historical weekly percentiles, and points representing the historical median and daily values
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily weekly_frequency_plot(gw_level_dv, gwl_data = NULL, date_col = "Date", value_col = "X_62610_00001", approved_col = "X_62610_00001_cd") gwl_data <- L2701_example_data$Discrete weekly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610") weekly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610", flip = TRUE)
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily weekly_frequency_plot(gw_level_dv, gwl_data = NULL, date_col = "Date", value_col = "X_62610_00001", approved_col = "X_62610_00001_cd") gwl_data <- L2701_example_data$Discrete weekly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610") weekly_frequency_plot(gw_level_dv, gwl_data = gwl_data, parameter_cd = "62610", flip = TRUE)
The weekly frequency analysis is based on daily, discrete, or both types of data. The median of each year/week combo is calculated, then overall weekly statistics are calculated off of that median.
weekly_frequency_table( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, flip = FALSE )
weekly_frequency_table( gw_level_dv, gwl_data, parameter_cd = NA, date_col = NA, value_col = NA, approved_col = NA, stat_cd = NA, flip = FALSE )
gw_level_dv |
data frame, daily groundwater level data. Often obtained
from |
gwl_data |
data frame returned from |
parameter_cd |
If data in gw_level_dv comes from NWIS, the parameter_cd
can be used to define the value_col. If the data doesn't come directly from
NWIS services, this can be set to |
date_col |
the name of the date column. The default is |
value_col |
the name of the value column. The default is |
approved_col |
the name of the column to get provisional/approved status.
The default is |
stat_cd |
If data in gw_level_dv comes from NWIS, the stat_cd can be used to help define the value_col. |
flip |
logical. If |
a data frame of weekly frequency analysis
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily weekly_frequency <- weekly_frequency_table(gw_level_dv, NULL, parameter_cd = "62610") head(weekly_frequency) gwl_data <- L2701_example_data$Discrete weekly_frequency <- weekly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610") weekly_frequency weekly_flip <- weekly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610", flip = TRUE) weekly_flip
# site <- "263819081585801" p_code_dv <- "62610" statCd <- "00001" # gw_level_dv <- dataRetrieval::readNWISdv(site, p_code_dv, statCd = statCd) gw_level_dv <- L2701_example_data$Daily weekly_frequency <- weekly_frequency_table(gw_level_dv, NULL, parameter_cd = "62610") head(weekly_frequency) gwl_data <- L2701_example_data$Discrete weekly_frequency <- weekly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610") weekly_frequency weekly_flip <- weekly_frequency_table(gw_level_dv, gwl_data, parameter_cd = "62610", flip = TRUE) weekly_flip