Produces a a rolling time-window based vector of medians and confidence intervals.
Arguments
- .tbl
a data frame with at least two variables; time column formatted as date, date/time and value column.
- x
column containing the numeric values to calculate the mean.
- tcolumn
formatted time column.
- unit
character, one of "years", "months", "weeks", "days", "hours", "minutes", "seconds"
- n
numeric, describing the length of the time window.
- ...
additional arguments passed to
median_ci
Examples
## Return a tibble with new rolling median column
tbr_median(Dissolved_Oxygen, x = Average_DO, tcolumn = Date, unit = "years",
n = 5)
#> # A tibble: 236 × 9
#> Station_ID Date Param_Code Param_Desc Average_DO Min_DO median lwr_ci
#> <int> <date> <chr> <chr> <dbl> <dbl> <dbl> <lgl>
#> 1 12515 2000-01-03 00300 OXYGEN, DIS… 6.19 6.19 NA NA
#> 2 12515 2000-03-14 00300 OXYGEN, DIS… 6.7 6.7 6.7 NA
#> 3 12517 2000-03-14 00300 OXYGEN, DIS… 7.3 7.3 6.7 NA
#> 4 12515 2000-03-16 00300 OXYGEN, DIS… 6.41 6.41 6.56 NA
#> 5 12515 2000-05-03 00300 OXYGEN, DIS… 4.42 4.42 6.41 NA
#> 6 12517 2000-06-14 00300 OXYGEN, DIS… 5.74 5.74 6.3 NA
#> 7 12515 2000-06-15 00300 OXYGEN, DIS… 4.86 4.86 6.19 NA
#> 8 12515 2000-07-11 00300 OXYGEN, DIS… 4.48 4.48 5.96 NA
#> 9 12515 2000-09-12 00300 OXYGEN, DIS… 5.64 5.64 5.74 NA
#> 10 12517 2000-10-17 00300 OXYGEN, DIS… 7.96 7.96 5.96 NA
#> # ℹ 226 more rows
#> # ℹ 1 more variable: upr_ci <lgl>
if (FALSE) { # \dontrun{
## Return a tibble with rolling median and 95% CI
tbr_median(Dissolved_Oxygen, x = Average_DO, tcolumn = Date, unit = "years", n = 5, conf = .95)} # }