pad_to_year | R Documentation |
Generic padding function. Generates a sequence from lubridate::floor(start_date, "year")
to lubridate::ceil(end_date, "year")
. The last point is excluded if end_date != max(data[[date_col]])
.
Under the hood the heavy lifting is done by tidyr::complete()
.
pad_to_year(
data,
date_col,
interval,
fill = list(),
start_date = NULL,
end_date = NULL
)
data |
input data |
date_col |
column containing date information, every date should be unique |
interval |
interval between two dates |
fill |
A named list that for each variable supplies a single value to use instead of NA for missing combinations. |
start_date |
optional start_date instead of |
end_date |
optional start_date instead of |
padded data
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_min30_2013_Jan.csv")
data <- rOstluft::read_airmo_csv(fn)
data <- rOstluft::rolf_to_openair(data)
# last data point is at 2013-01-31 23:30:00
tail(data)
# the site column get filled with NA, this could lead to problems
tail(pad_to_year(data, date, "30 min"))
# better to provide a fill value, for more complex cases use pad_to_year_fill()
tail(pad_to_year(data, date, "30 min", fill = list(site = "Zch_Stampfenbachstrasse")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.