mkann {seas} | R Documentation |
Make annum from a date
Description
Discretizes a date into an annum, using a starting day to specify the start of a season, and ends in the next year.
Usage
mkann(x, start.day, calendar)
Arguments
x |
A It may also be a vector of |
start.day |
This is the starting day of the annum, and can be
specified as either a |
calendar |
if unspecified, it will be attempted to be read from
|
Details
This date function finds the annual-breaks between seasons, using a
start.day
. Often, the start.day
is 1, or January 1st,
in which case simply the year is returned, since the season starts on
January 1 and ends on December 31st. Otherwise, each annual break is
set using start.day
, and the annum is identified by the range
of years, for example 1991_1992
, identifying a season starting on
start.day
in 1991, and ending in the day before
start.day
in 1992.
The length of each year depends on the calendar; see
year.length
for details.
A choice of start.day
can influence annual totals using
seas.sum
, such as annual precipitation. For instance, if
a particular winter in the Northern hemisphere has snow before and
after the new year, these would be divided counting annual sums based
on the year, whereas if start.day
were before the winter
season, the annual sum would be calculated throughout the winter
season.
Value
Returns factor
s for each date given in x
, grouped
by each annum.
Author(s)
Mike Toews
References
https://en.wikipedia.org/wiki/Gregorian_calendar
See Also
Examples
data(mscdata)
dat <- mksub(mscdata, id=1108447)
dat$ann1 <- mkann(dat, start.day=1)
dat$ann2 <- mkann(dat, start.day=as.Date("2000-02-01"))
dat$ann3 <- mkann(dat, start.day=as.Date("2000-08-01"))
table(dat$ann1)
table(dat$ann2)
table(dat$ann3)
dat[26:36, c("date", paste("ann", 1:3, sep=""))]