Produces a a rolling time-window based vector of means and confidence intervals.
tbr_mean(.tbl, x, tcolumn, unit = "years", n, ...)
a data frame with at least two variables; time column formatted as date, date/time and value column.
column containing the numeric values to calculate the mean.
formatted time column.
character, one of "years", "months", "weeks", "days", "hours", "minutes", "seconds"
numeric, describing the length of the time window.
additional arguments passed to mean_ci
.
tibble with columns for the rolling mean and upper and lower confidence intervals.
## Return a tibble with new rolling mean column
tbr_mean(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 mean lwr_ci
#> <int> <date> <chr> <chr> <dbl> <dbl> <dbl> <lgl>
#> 1 12515 2000-01-03 00300 OXYGEN, DISS… 6.19 6.19 NA NA
#> 2 12515 2000-03-14 00300 OXYGEN, DISS… 6.7 6.7 6.73 NA
#> 3 12517 2000-03-14 00300 OXYGEN, DISS… 7.3 7.3 6.73 NA
#> 4 12515 2000-03-16 00300 OXYGEN, DISS… 6.41 6.41 6.65 NA
#> 5 12515 2000-05-03 00300 OXYGEN, DISS… 4.42 4.42 6.20 NA
#> 6 12517 2000-06-14 00300 OXYGEN, DISS… 5.74 5.74 6.13 NA
#> 7 12515 2000-06-15 00300 OXYGEN, DISS… 4.86 4.86 5.95 NA
#> 8 12515 2000-07-11 00300 OXYGEN, DISS… 4.48 4.48 5.76 NA
#> 9 12515 2000-09-12 00300 OXYGEN, DISS… 5.64 5.64 5.75 NA
#> 10 12517 2000-10-17 00300 OXYGEN, DISS… 7.96 7.96 5.97 NA
#> # … with 226 more rows, and 1 more variable: upr_ci <lgl>
if (FALSE) {
## Return a tibble with rolling mean and 95% CI
tbr_mean(Dissolved_Oxygen, x = Average_DO, tcolumn = Date, unit = "years", n = 5, conf = .95)}