
Summarise a rOstluft::format_rolf() dataset over periodic (diurnal, weekday, etc) factors implicitly created by cut_timeseries_periodic() using various stat functions.
Source: R/summary_periodic.R
summary_periodic.RdInput data should be rOstluft::format_rolf() data.
Arguments
- data
a data.frame or tibble containing the data
- y
a character string specifying the taget variable to be summarised, usually "value".
- groupings
additional groupings. Use helper
grp()to create; groupings must be from possible outcomes ofcut_timeseries_periodic().- fun
function or list of functions for summary, can be named (then the outut stat is named after the function's name); Strings matching the regular expression
/^percentile([0-9]){1,2}$/iare converted into the respective function. "percentile95" =>function(x, ...) quantile(x, 95 / 100, ...)- fun.args
a list of extra arguments passed on to fun.
- nmin
numeric, minimum number of values for fun, if n < nmin: NA is returned
- coords
a named vector of the location in WGS84 coordinates for the daylight factoring.
suncalc::getSunlightTimes()is used to calculate sunrise, sunset times. Default: c(lat = 47.36667, lon = 8.55) => Zuerich, Switzerland
Computed variables
as determined by cut_timeseries_periodic() in combination with grouping
The names of the columns stay the same as in data.
factor columns according to the groups specified in
groupingfactor column
statcontaining the name of the summarize function as levelcolumn
valuewith the result of the summarize functionncount of occurrences for the corresponding binfreqfrequency of the corresponding bin
Examples
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_2010-2014.csv")
data <-
rOstluft::read_airmo_csv(fn) %>%
rOstluft::pluck_parameter("NOx", "O3", "PM10") %>%
rOstluft::resample(new_interval = "h1")
fun <- list(middle = "mean", middle2 = "median", ymin = "percentile05",
lower = "percentile25", upper = "percentile75", ymax = "percentile95")
data_summarized <- summary_periodic(data, fun = fun)
data_summarized
#> # A tibble: 432 × 9
#> starttime_of_day site parameter interval unit n freq stat value
#> <ord> <fct> <fct> <fct> <fct> <int> <dbl> <fct> <dbl>
#> 1 00:00 Zch_Stampf… NOx h1 ppb 1826 0.333 midd… 24.0
#> 2 00:00 Zch_Stampf… NOx h1 ppb 1826 0.333 midd… 17.1
#> 3 00:00 Zch_Stampf… NOx h1 ppb 1826 0.333 ymin 4.07
#> 4 00:00 Zch_Stampf… NOx h1 ppb 1826 0.333 lower 9.05
#> 5 00:00 Zch_Stampf… NOx h1 ppb 1826 0.333 upper 30.6
#> 6 00:00 Zch_Stampf… NOx h1 ppb 1826 0.333 ymax 68.3
#> 7 00:00 Zch_Stampf… O3 h1 µg/m3 1826 0.333 midd… 38.0
#> 8 00:00 Zch_Stampf… O3 h1 µg/m3 1826 0.333 midd… 38.6
#> 9 00:00 Zch_Stampf… O3 h1 µg/m3 1826 0.333 ymin 1.29
#> 10 00:00 Zch_Stampf… O3 h1 µg/m3 1826 0.333 lower 12.5
#> # ℹ 422 more rows