Skip to contents

Weekly statistics are calculated using the weekly_frequency_table function. Daily, discrete, or both types of data can be used.

Usage

weekly_frequency_plot(
  gw_level_dv,
  gwl_data,
  parameter_cd = NA,
  date_col = c("time", "time"),
  value_col = c("value", "value"),
  approved_col = c("approval_status", "approval_status"),
  plot_range = "Past year",
  plot_title = "",
  subtitle = "U.S. Geological Survey",
  y_axis_label = "",
  flip = FALSE,
  percentile_colors = NA
)

Arguments

gw_level_dv

data frame, daily groundwater level data. Often obtained from read_waterdata_daily. Use NULL for no daily data.

gwl_data

data frame returned from read_waterdata_field_measurements, or data frame with a date, value, and approval columns. Use NULL for no discrete data.

parameter_cd

Can be used to filter data if the data frame has a "parameter_code" column. The default is NA, which will not do any filtering. If the gwl_data and gw_level_dv need different parameter code filtering, use a vector of 2 parameter codes. The first one will filter the gw_level_dv data frame, the second will filter the gwl_data data frame.

date_col

the name of the time columns. The first value is associated with the gw_level_dv input, and the second value is associated with the gwl_data input. The default is c("time", "time").

value_col

the name of the value columns. The first value is associated with the gw_level_dv input, and the second value is associated with the gwl_data input. The default is c("value", "value").

approved_col

the name of the column to get provisional/approved status. The first value is associated with the gw_level_dv input, and the second value is associated with the gwl_data input. The default is c("approval_status", "approval_status"). It is expected that these columns will have only "Approved" or "Provisional".

plot_range

the time frame to use for the plot. Use "Past year" (default) to see the last year of data, or "Calendar year" to use the current calendar year, beginning in January. Or specify two dates representing the start and end of the plot. If the first date is NA, it will start at the earliest record, if the second date is NA, it will end at the latest record.

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 TRUE, flips labels so that the lower numbers are in the higher percentages. Default is TRUE.

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.

Value

a ggplot object with rectangles representing the historical weekly percentiles, and points representing the historical median and daily values

Examples


site <- "USGS-263819081585801"
p_code_dv <- "62610"
statCd <- "00001"

# gwl_data <- dataRetrieval::read_waterdata_field_measurements(monitoring_location_id = site, 
#                                  skipGeometry = TRUE)
gwl_data <- L2701_example_data$Discrete

# gw_level_dv <- dataRetrieval::read_waterdata_daily(monitoring_location_id = site,
#                                                    parameter_code = p_code_dv,
#                                                    statistic_id = statCd,
#                                                    skipGeometry = TRUE)
#
                                                    
gw_level_dv <- L2701_example_data$Daily

weekly_frequency_plot(gw_level_dv,
                      gwl_data = NULL)
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).

                      
weekly_frequency_plot(gw_level_dv,
                      gwl_data = gwl_data,
                      parameter_cd = "62610",
                      plot_range = c("2023-10-01", "2024-09-30"))
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).


weekly_frequency_plot(gw_level_dv,
                      gwl_data = gwl_data,
                      parameter_cd = "62610")
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).


weekly_frequency_plot(gw_level_dv,
                      gwl_data = gwl_data,
                      parameter_cd = "62610",
                      flip = TRUE)
#> Warning: Removed 1 row containing missing values or values outside the scale range
#> (`geom_point()`).