Find Season of Particular Date in R (Example Code)
In this R tutorial you’ll learn how to return the seasons of specific dates.
Creation of Example Data
x <- as.Date(c("2022-11-11", # Create vector of dates "2021-05-02", "2025-12-17", "2023-08-01")) x # [1] "2022-11-11" "2021-05-02" "2025-12-17" "2023-08-01" |
x <- as.Date(c("2022-11-11", # Create vector of dates "2021-05-02", "2025-12-17", "2023-08-01")) x # [1] "2022-11-11" "2021-05-02" "2025-12-17" "2023-08-01"
Example: Convert Dates to Seasons
install.packages("hydroTSM") # Install & load hydroTSM library("hydroTSM") |
install.packages("hydroTSM") # Install & load hydroTSM library("hydroTSM")
time2season(x, out.fmt = "seasons") # Get seasons # [1] "autumm" "spring" "winter" "summer" |
time2season(x, out.fmt = "seasons") # Get seasons # [1] "autumm" "spring" "winter" "summer"