season: Attribute dates to seasons

View source: R/misc.R

seasonR Documentation

Attribute dates to seasons

Description

Based on a vector of breaks (start dates) dates are classified into seasons.

Usage

season(x, start = c(winter = as.Date("2005-12-01"),
                    spring = as.Date("2005-03-01"),
                    summer = as.Date("2005-06-01"),
                    autumn = as.Date("2005-09-01")))

Arguments

x

Vector of dates to be classified into seasons. Methods for class 'numeric', 'Date' and 'POSIXct' exist. If input is numeric it is assumed to be the day of the year (see strptime '%j').

start

Possibly named vector of starts of a season. If the vector is unnamed generic names are used and a warning is risen.

Value

Factor of classifications of seasons.

See Also

link{apply.seasonal}

Examples

# input vector is of class Date
times <- seq(from = Sys.Date(), to = Sys.Date() + 500, by = 20)
season(times)

# input vector is numeric (the day of the year)
n <- as.numeric(format(times, "%j"))
season(n)

identical(season(times), season(n))

lfstat documentation built on Nov. 10, 2022, 5:42 p.m.