Description Usage Arguments Details Value Author(s) Examples
View source: R/assign_season.R
Assign seasons to SWMPr sampling data on a monthly basis or user-defined seasonal basis
1 2 3 4 5 6 7 |
data |
a vector of POSIXct dates |
season_grps |
A list of seasons. Months (1-12) are assigned to different groups based on user preference. Defaults to 12 months, starting with January. Must assign a minimum of two seasons |
season_names |
A string vector of season names. The number of season names must match the length of the |
season_start |
defaults to 12 months, starting with January |
abb |
logical, should abbreviations for month names be used? Defaults to |
A helper function used by multiple data analyses to assign seasons to sampling data and to order the seasons. To assist with plotting, the seasons are assigned as factors. Seasons are assigned by first grouping the months into a list of season_grps and then specifying one name for each grouping using season_names. If season_grps is specified then season_names must also be defined. If neither argument is specified than the season assignments will default to monthly values. Using the season_start argument, the user can designate which season should be the first factor level. This assignment affects plot order for most functions. If season_start is not specified, then it will default to the first season in the list (January for monthly seasons and the first season in season_names for user-defined seasons).
Returns a vector of ordered season factors.
Julie Padilla
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | data(elksmwq)
dat <- elksmwq
seas <- assign_season(dat$datetimestamp, abb = FALSE)
levels(seas)
seas <- assign_season(dat$datetimestamp, abb = TRUE)
levels(seas)
seas <- assign_season(dat$datetimestamp, season_start = 'Mar')
levels(seas)
seas <- assign_season(dat$datetimestamp, abb = FALSE, season_start = 'March')
levels(seas)
seas <- assign_season(dat$datetimestamp,
season_grps = list(c(1,2,3), c(4,5,6), c(7,8,9), c(10, 11, 12)),
season_names = c('Winter', 'Spring', 'Summer', 'Fall'), season_start = 'Spring')
levels(seas)
seas <- assign_season(dat$datetimestamp, season_grps = list(c(10:12, 1:3), c(4:9)),
season_names = c('Wet', 'Dry'))
levels(seas)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.