Skip to contents

Cut a POSIXct Vector into weekday and weekend

Usage

cut_weekend(x, label = c("Wochentag", "Wochenende"))

Arguments

x

a datetime object.

label

Vector of label for weekday and weekend in order weekday, weekend

Value

ordered factor weekday > weekend

Examples

fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_d1_2013_Jan.csv")
data <- rOstluft::read_airmo_csv(fn)

data <- dplyr::mutate(data,
  weekend_ger = cut_weekend(.data$starttime),
  weekend_eng =  cut_weekend(.data$starttime, c("weekday", "weekend"))
)

tibble::glimpse(data)
#> Rows: 2,170
#> Columns: 8
#> $ starttime   <dttm> 2013-01-01, 2013-01-02, 2013-01-03, 2013-01-04, 2013-01-0…
#> $ site        <fct> Zch_Stampfenbachstrasse, Zch_Stampfenbachstrasse, Zch_Stam…
#> $ parameter   <fct> CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO…
#> $ interval    <fct> d1, d1, d1, d1, d1, d1, d1, d1, d1, d1, d1, d1, d1, d1, d1…
#> $ unit        <fct> mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg…
#> $ value       <dbl> 0.3807054, 0.3404095, 0.4225526, 0.4332204, 0.3367749, 0.2…
#> $ weekend_ger <ord> Wochentag, Wochentag, Wochentag, Wochentag, Wochenende, Wo…
#> $ weekend_eng <ord> weekday, weekday, weekday, weekday, weekend, weekend, week…