Skip to contents

Cut a POSIXct Vector into time of day (HH:MM)

Usage

cut_time_of_day(x)

Arguments

x

a datetime object.

Value

ordered factor with time of day

Examples

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

data <- dplyr::mutate(data,
  "Etc/GMT-1" = cut_time_of_day(.data$starttime),
  utc = cut_time_of_day(lubridate::force_tz(.data$starttime, "UTC")),
  utc_converted = cut_time_of_day(lubridate::with_tz(.data$starttime, "UTC")),
  berlin = cut_time_of_day(lubridate::force_tz(.data$starttime, "Europe/Berlin"))
)

tibble::glimpse(data)
#> Rows: 14,116
#> Columns: 10
#> $ starttime     <dttm> 2013-01-01 00:00:00, 2013-01-01 01:00:00, 2013-01-01 02…
#> $ site          <fct> Zch_Stampfenbachstrasse, Zch_Stampfenbachstrasse, Zch_St…
#> $ parameter     <fct> CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, …
#> $ interval      <fct> h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, …
#> $ unit          <fct> mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, …
#> $ value         <dbl> 0.8051369, 0.8326345, 0.8742825, 0.7549847, 0.7667311, 0…
#> $ `Etc/GMT-1`   <ord> 00:00, 01:00, 02:00, 03:00, 04:00, 05:00, 06:00, 07:00, …
#> $ utc           <ord> 00:00, 01:00, 02:00, 03:00, 04:00, 05:00, 06:00, 07:00, …
#> $ utc_converted <ord> 23:00, 00:00, 01:00, 02:00, 03:00, 04:00, 05:00, 06:00, …
#> $ berlin        <ord> 00:00, 01:00, 02:00, 03:00, 04:00, 05:00, 06:00, 07:00, …