mkann                  package:seas                  R Documentation

_M_a_k_e _a_n_n_u_m _f_r_o_m _a _d_a_t_e

_D_e_s_c_r_i_p_t_i_o_n:

     Discretizes a date into an annum, using a starting day to specify
     the start of a season, and ends in the next year.

_U_s_a_g_e:

     # normal usage, where 'x' is a data.frame with a date column
     mkann(x)

     # all options
     mkann(x, start.day, calendar)

_A_r_g_u_m_e_n_t_s:

       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'

_D_e_t_a_i_l_s:

     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.

_V_a_l_u_e:

     Returns 'factor's for each date given in 'x', grouped by each
     annum.

_A_u_t_h_o_r(_s):

     M.W. Toews

_R_e_f_e_r_e_n_c_e_s:

     <URL: http://en.wikipedia.org/wiki/Gregorian_calendar>

_S_e_e _A_l_s_o:

     'mkseas', 'seas.sum'

_E_x_a_m_p_l_e_s:

     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=""))]

