season: Get Season Based on a Date

View source: R/season.r

seasonR Documentation

Get Season Based on a Date

Description

This function determines the season (Winter, Spring, Summer, or Fall) based on an input date.

Usage

season(input_date)

Arguments

input_date

A Date or POSIXct object representing the date to determine the season for. The input must be of class Date or POSIXct.

Details

The seasons are assigned based on geographic regions similar to how seasons occur in the United States.

The seasons are determined using the month of the year and the traditional meteorological definition of seasons (Winter: December, January, February; Spring: March, April, May; Summer: June, July, August; Fall: September, October, November).

Value

A factor indicating the season corresponding to the input date. The factor levels are:

  • "Winter" for December, January, and February.

  • "Spring" for March, April, and May.

  • "Summer" for June, July, and August.

  • "Fall" for September, October, and November.

  • "Undetermined" if the input is not a valid Date or POSIXct object or if the month is missing.

Author(s)

Nicolas Foss, Ed.D., MS

Examples

# Example usage of the season function
season(as.Date("2025-01-15"))
season(as.POSIXct("2025-07-01 12:00:00"))


traumar documentation built on April 3, 2025, 11:55 p.m.