Cut a POSIXct Vector into daylight (day, night)
Usage
cut_daylight(x, coords = c(lat = 47.36667, lon = 8.55))
Arguments
- x
a POSIXct Vector with a timezone
- coords
a named vector of the location in WGS84 coordinates for the daylight factoring.
suncalc::getSunlightTimes()
is used to calculate sunrise, sunset times. Default: c(lat = 47.36667, lon = 8.55) => Zuerich, Switzerland
Examples
fn <- rOstluft.data::f("Zch_Stampfenbachstrasse_h1_2013_Jan.csv")
data <- rOstluft::read_airmo_csv(fn)
data <- dplyr::mutate(data,
daylight_zuerich = cut_daylight(.data$starttime),
daylight_sidney = cut_daylight(.data$starttime, c(lat = -33.9, lon = 151.2))
)
tibble::glimpse(data)
#> Rows: 14,116
#> Columns: 8
#> $ starttime <dttm> 2013-01-01 00:00:00, 2013-01-01 01:00:00, 2013-01-01…
#> $ site <fct> Zch_Stampfenbachstrasse, Zch_Stampfenbachstrasse, Zch…
#> $ parameter <fct> CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, CO, C…
#> $ interval <fct> h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h1, h…
#> $ unit <fct> mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m3, mg/m…
#> $ value <dbl> 0.8051369, 0.8326345, 0.8742825, 0.7549847, 0.7667311…
#> $ daylight_zuerich <ord> Nacht, Nacht, Nacht, Nacht, Nacht, Nacht, Nacht, Nach…
#> $ daylight_sidney <ord> Tag, Tag, Tag, Tag, Tag, Tag, Tag, Tag, Tag, Tag, Tag…