Skip to contents

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.

Usage

weekly_frequency_table(
  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"),
  flip = FALSE
)

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".

flip

logical. If TRUE, flips labels so that the lower numbers are in the higher percentages. Default is TRUE.

Value

a data frame of weekly frequency analysis

Examples


site <- "USGS-263819081585801"
p_code_dv <- "62610"
statCd <- "00001"
# gw_level_dv <- dataRetrieval::read_waterdata_daily(monitoring_location_id = site,
#                                                    parameter_code = p_code_dv,
#                                                    statistic_id = statCd)
                                                    
gw_level_dv <- L2701_example_data$Daily

weekly_frequency <- weekly_frequency_table(gw_level_dv, NULL)
head(weekly_frequency)
#> # A tibble: 6 × 12
#>    week   p05   p10   p25   p50   p75   p90   p95 nYears minMed maxMed
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <int>  <dbl>  <dbl>
#> 1     1 -37.7 -32.9 -28.7 -20.7 -16.2 -10.6 -8.67     45  -40.6  -5.48
#> 2     2 -38.0 -32.5 -28.3 -20.2 -16.1 -10.7 -7.54     46  -41.4  -5.52
#> 3     3 -37.9 -32.5 -28.5 -20.5 -16.4 -10.8 -6.54     46  -42.1  -5.68
#> 4     4 -38.9 -31.7 -28.6 -21.0 -16.8 -10.9 -7.09     46  -41.9  -6.12
#> 5     5 -39.9 -31.7 -28.8 -21.2 -17.2 -11.4 -7.20     47  -41.6  -6.8 
#> 6     6 -40.1 -32.1 -28.9 -21.3 -17.4 -11.9 -7.94     47  -42.1  -7.02
#> # ℹ 1 more variable: week_start <chr>

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

weekly_frequency <- weekly_frequency_table(gw_level_dv,
                                           gwl_data,
                                           parameter_cd = "62610")
head(weekly_frequency)
#> # A tibble: 6 × 12
#>    week   p05   p10   p25   p50   p75   p90   p95 nYears minMed maxMed
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <int>  <dbl>  <dbl>
#> 1     1 -37.7 -32.9 -28.7 -20.7 -16.2 -10.5 -8.67     45  -40.6  -5.48
#> 2     2 -38.0 -32.5 -28.3 -20.2 -16.2 -10.7 -7.54     46  -41.4  -5.52
#> 3     3 -37.9 -32.5 -28.5 -20.5 -16.4 -10.8 -6.54     46  -42.1  -5.68
#> 4     4 -39.0 -31.8 -28.6 -21.0 -16.8 -10.9 -7.09     46  -42.4  -6.12
#> 5     5 -39.9 -31.7 -29.2 -21.2 -17.2 -11.4 -7.20     47  -41.6  -6.8 
#> 6     6 -40.1 -32.1 -28.9 -21.3 -17.4 -11.9 -7.94     47  -42.1  -7.02
#> # ℹ 1 more variable: week_start <chr>
weekly_flip <- weekly_frequency_table(gw_level_dv,
                                      gwl_data,
                                      parameter_cd = "62610",
                                      flip = TRUE)
head(weekly_flip)
#> # A tibble: 6 × 12
#>    week   p05   p10   p25   p50   p75   p90   p95 nYears minMed maxMed
#>   <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>  <int>  <dbl>  <dbl>
#> 1     1 -8.67 -10.5 -16.2 -20.7 -28.7 -32.9 -37.7     45  -5.48  -40.6
#> 2     2 -7.54 -10.7 -16.2 -20.2 -28.3 -32.5 -38.0     46  -5.52  -41.4
#> 3     3 -6.54 -10.8 -16.4 -20.5 -28.5 -32.5 -37.9     46  -5.68  -42.1
#> 4     4 -7.09 -10.9 -16.8 -21.0 -28.6 -31.8 -39.0     46  -6.12  -42.4
#> 5     5 -7.20 -11.4 -17.2 -21.2 -29.2 -31.7 -39.9     47  -6.8   -41.6
#> 6     6 -7.94 -11.9 -17.4 -21.3 -28.9 -32.1 -40.1     47  -7.02  -42.1
#> # ℹ 1 more variable: week_start <chr>