enumerate_seasons: Enumerate seasons in data frame

Description Usage Arguments Value Examples

View source: R/enumerate_seasons.R

Description

enumerate_seasons categorizes rows by an annual season defined by start_* and end_* parameters. The resulting object includes a season_year column indicating which season the date is considered part of. This is generally only used for internal data processing by summarize_* functions.

Usage

1
2
3
4
5
6
7
enumerate_seasons(
  data,
  start_month,
  end_month,
  start_day = 15,
  end_day = start_day
)

Arguments

data

long-format data frame with weather data including a column date; ideally the data object is the result of a call to to_long

start_month

numeric starting month defining season (inclusive)

end_month

numeric ending month defining season (inclusive)

start_day

numeric day of starting month defining season (inclusive); defaults to 15

end_day

numeric day of ending month defining season (inclusive); defaults to start_day

Value

A copy of the passed data data frame with an additional column, season_year indicating the year of the season that the observation "belongs" to. For seasons that do not cross the new year, this is simply the year the observation was made. For seasons that do include the new year (e.g. a season starts in November and ends in the subsequent March), season_year is defined as the year in which the season starts. That is, for a season spanning November through March, the value of season_year for observations in January, February, and March is the prior year (e.g. season_year for an observation on 1983-02-01 for a season spanning November through March would be 1984).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
# to_long and enumerate_seasons are internal functions, hence the triple-
colon (:::)
# enumerate_seasons expects long-formatted data
rain_long <- wxsumR:::to_long(data = rain_2yr)

# enumerate seasons, defined by 30 November through 15 March
rain_seasons <- wxsumR:::enumerate_seasons(data = rain_long,
                                                   start_month = 11,
                                                   end_month = 3,
                                                   start_day = 30,
                                                   end_day = 15)

## End(Not run)

jcoliver/weathercommand documentation built on Sept. 12, 2021, 3:28 a.m.