Skip to contents

Cut the data in year-season intervals while keeping the seasons together. This means december will be added to the following year.

With label = "year" only the year will be adjustet.

Usage

cut_seasonyear(x, label = c("yearseason", "year"), labels = NULL)

Arguments

x

a date-time vector

label

choice between c("yearseason", "year"). "yearseason" will combine the year and the output from cut_season(), "year" will return only the adjusted year.

labels

forwarded to cut_season()

Value

factor of yearseasons

Examples

dates <- lubridate::ymd(010101) + months(0:11)

cut_seasonyear(dates)
#>  [1] 2001-DJF 2001-DJF 2001-MAM 2001-MAM 2001-MAM 2001-JJA 2001-JJA 2001-JJA
#>  [9] 2001-SON 2001-SON 2001-SON 2002-DJF
#> Levels: 2001-DJF < 2001-MAM < 2001-JJA < 2001-SON < 2002-DJF

cut_seasonyear(dates, "year")
#>  [1] 2001 2001 2001 2001 2001 2001 2001 2001 2001 2001 2001 2002
#> Levels: 2001 < 2002

# customize season labels
labels =  c(
  DJF = "winter", JJA = "summer",
  MAM = "spring", SON = "autumn"
)

cut_seasonyear(dates, labels = labels)
#>  [1] 2001-winter 2001-winter 2001-spring 2001-spring 2001-spring 2001-summer
#>  [7] 2001-summer 2001-summer 2001-autumn 2001-autumn 2001-autumn 2002-winter
#> 5 Levels: 2001-winter < 2001-spring < 2001-summer < ... < 2002-winter