Produces a a rolling time-window based vector of geometric means and confidence intervals.

tbr_gmean(.tbl, x, tcolumn, unit = "years", n, ...)

Arguments

.tbl

a data frame with at least two variables; time column formatted as date, date/time and value column.

x

column containing the values to calculate the geometric 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 gm_mean_ci

Value

tibble with columns for the rolling geometric mean and upper and lower confidence levels.

See also

Examples


## Return a tibble with new rolling geometric mean column
tbr_gmean(Dissolved_Oxygen, x = Average_DO, tcolumn = Date, unit = "years", n = 5)
#> # A tibble: 236 × 7
#>    Station_ID Date       Param_Code Param_Desc           Average_DO Min_DO  mean
#>         <int> <date>     <chr>      <chr>                     <dbl>  <dbl> <dbl>
#>  1      12515 2000-01-03 00300      OXYGEN, DISSOLVED (…       6.19   6.19 NA   
#>  2      12515 2000-03-14 00300      OXYGEN, DISSOLVED (…       6.7    6.7   6.71
#>  3      12517 2000-03-14 00300      OXYGEN, DISSOLVED (…       7.3    7.3   6.71
#>  4      12515 2000-03-16 00300      OXYGEN, DISSOLVED (…       6.41   6.41  6.64
#>  5      12515 2000-05-03 00300      OXYGEN, DISSOLVED (…       4.42   4.42  6.12
#>  6      12517 2000-06-14 00300      OXYGEN, DISSOLVED (…       5.74   5.74  6.05
#>  7      12515 2000-06-15 00300      OXYGEN, DISSOLVED (…       4.86   4.86  5.87
#>  8      12515 2000-07-11 00300      OXYGEN, DISSOLVED (…       4.48   4.48  5.67
#>  9      12515 2000-09-12 00300      OXYGEN, DISSOLVED (…       5.64   5.64  5.67
#> 10      12517 2000-10-17 00300      OXYGEN, DISSOLVED (…       7.96   7.96  5.86
#> # … with 226 more rows

if (FALSE) {
## Return a tibble with rolling geometric mean and 95% CI
tbr_gmean(Dissolved_Oxygen, x = Average_DO, tcolumn = Date, unit = "years", n = 5, conf = .95)}