wmean | R Documentation |
Sometimes records (e.g. measurements from passive samplers or miniDOAS) provide values representative irregular time intervals such as starting from odd start times to odd end times. For example 09:58 to 10:08 or 20 Feb to 06 March. This function interpolates the irregular data on a standard interval. It handles down- and upsampling correct.
wmean(
data,
...,
starttime = "starttime",
endtime = "endtime",
value = "value",
interval = "h1"
)
data |
data.frame for averaging; df has to be in long format and contain a start- and end-time column of class POSIXct (arbitrarily named) |
... |
columns containing values for grouping (passed to |
starttime |
name of starttime column as symbol or string |
endtime |
name of endtime column as symbol or string |
value |
name of column containing values to be averaged as symbol or string |
interval |
specifying the output interval for averaging as string |
tibble with the starttime, endtime, value and grouping columns and additional the column "n" containing the sum of weighted intervals within the averaged time interval (data availability in interval, 1 = 100\
Removes NA values to correctly calculate data availability for each interval
output data isn't padded
fn <- system.file("extdata", "Zch_Stampfenbachstrasse_h1_2013_Jan.csv", package = "rOstluft.data")
ps_fn <- system.file("extdata", "NO2_PS.rds", package = "rOstluft.data")
data <- read_airmo_csv(fn, time_shift = lubridate::period(25, "minutes"))
data_ps <- readRDS(ps_fn) %>% pluck_site("Zch_Stampfenbachstrasse")
df <- pluck_parameter(data, "CO") %>%
pluck_unit("ppm") %>%
dplyr::mutate(endtime = .data$starttime + lubridate::hours(1)) %>%
dplyr::select(-interval)
wmean(df, site, parameter, unit, interval = "h1")
wmean(df, site, parameter, unit, interval = "m1")
wmean(df, site, parameter, unit, interval = "y1")
wmean(data_ps, site, parameter, unit, interval = "d1")
wmean(data_ps, site, parameter, unit, interval = "1 week")
wmean(data_ps, site, parameter, unit, interval = "m1")
wmean(data_ps, site, parameter, unit, interval = "y1")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.