season_year: Season year adjustment

Description Usage Arguments Details Value Examples

Description

When grouping data by season and year, creates a new variable for year with Summer years switched to financial year ending. Other years are left as calendar year.

Usage

1
season_year(x, shoulder = FALSE)

Arguments

x

A date-time object.

shoulder

Logical. If TRUE only Summer and Winter are are defined to include shoulder months. So summer will include October, November, December, January, February, March and Winter will include April, May, June, July, August, September. This results in financial year ending being calculated for October and November as well as the other summer months.

Details

This prevents Summer from being incorrectly grouped. E.g. if grouping summer months in 2015, January 2015, February 2015 and December 2015 will be grouped together which is not useful. Rather, we would want December 2014 to be included so that consecutive months are grouped.

Value

Calendar year for all seasons except Summer. Summer has financial year ending returned.

Examples

1
2
3
4
5
6
7
8
require(lubridate)
x <- dmy("1/12/2015") + months(0:12)
year(x)
# 2015 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016
season_year(x)
# 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2017
season_year(x, shoulder = TRUE)
# 2016 2016 2016 2016 2016 2016 2016 2016 2016 2016 2017 2017 2017

camroach87/myhelpr documentation built on May 13, 2019, 11:03 a.m.