mkann {seas} | R Documentation |
Discretizes a date into an annum, using a starting day to specify the start of a season, and ends in the next year.
# normal usage, where 'x' is a data.frame with a date column mkann(x) # all options mkann(x, start.day, calendar)
x |
A data.frame with a date column
(of Date or POSIXct class)
It may also be a vector of Date or
POSIXct class |
start.day |
This is the starting day of the annum, and can be
specified as either a Date , where year is ignored (e.g.,
as.Date("2000-08-01") for August 1st of any year); or it can
be a day of the year, from 1–365 |
calendar |
if unspecified, it will be attempted to be read from
attr(x$date ); otherwise it is assumed to be a normal
proleptic Gregorian calendar; see year.length |
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.
Returns factor
s for each date given in x
, grouped
by each annum.
M.W. Toews
http://en.wikipedia.org/wiki/Gregorian_calendar
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=""))]