Skip to contents

cut_date() conveniently extracts useful features from a vector of date-time data, such as the year, season, whether or not it is a weekend, and so on. This may be useful

Usage

cut_date(x, type, hemisphere = "northern")

Arguments

x

date(time) vector

type

The feature to extract from the vector. Can be any one of "year", "month", "hour", "yearmon", "weekday", "weekend", "season", or "seasonyear".

hemisphere

Used to split data into seasons. Can be "northern" (the default) or "southern".

Value

a factor vector.

Examples

if (FALSE) {
# vector
cut_date(openair::mydata$date, "year")
# data frame
dplyr::mutate(openair::mydata, year = cut_date(year))
}