cut_timeseries_periodic | R Documentation |
Appends new factor variables as columns to the dataset, for further use
with e.g. summary_periodic()
in order to calculate summary stats for
starttime of the day, date, weekday, weekend, week, month, season, daylight.
cut_timeseries_periodic(
data,
x = "starttime",
include_daylight = TRUE,
coords = c(lat = 47.36667, lon = 8.55)
)
data |
tibble containing a column starttime of type POSIXct with a timezone |
x |
symbolic reference to date time column used for cutting |
include_daylight |
boolean indicating to calculate daylight for each starttime. Disable to improve perfomance. |
coords |
a named vector of the location in WGS84 coordinates for the daylight factoring.
|
a tibble with cut data; cut-factors comprise various (time-)periodic new columns:
starttime_of_day: cut_time_of_day(x)
date: lubridate::as_date(x)
to preserve time zone don't use base::as.Date()
weekday: lubridate::wday(x, label = TRUE, week_start = 1)
locale Abbreviations
(Mon, Tue, Wed, Thu, Fri, Sat, Sun)
weekend: cut_weekend(x)
=> Wochentag, Wochenende (use cut_weekend()
manually or
recode factor to change levels)
week: lubridate::week(x)
month: lubridate::month(x, label = TRUE)
locale Abbreviations (Jan, Feb, Mar, ...)
season: cut_season(x)
=> DJF, MAM, JJA, SON (use cut_season()
manually or recode
factor to change levels)
daylight: cut_daylight(x, coords)
=> Tag, Nacht (use cut_daylight()
manually or
recode factor to change levels)
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_h1_2013_Jan.csv")
data <- rOstluft::read_airmo_csv(fn)
data <- cut_timeseries_periodic(data)
tibble::glimpse(data)
# recoding a factor
data <- dplyr::mutate(data,
daylight = dplyr::recode(daylight, Nacht = "night", Tag = "day"),
)
tibble::glimpse(data)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.