daystoyears             package:pastecs             R Documentation

_C_o_n_v_e_r_t _t_i_m_e _u_n_i_t_s _f_r_o_m "_d_a_y_s" _t_o "_y_e_a_r_s" _o_r _b_a_c_k

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

     Convert time scales. The time scale "days" corresponds to 1 unit
     per day. The time scale "years" uses 1 unit for 1 year. It is used
     in any analysis that requires seasonal decomposition and/or
     elimination.

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

     daystoyears(x, datemin=NULL, dateformat="m/d/Y")
     yearstodays(x, xmin=NULL)

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

       x: A vector of time values 

 datemin: A character string representing the first date, using a
          format corresponding to `dateformat'. For instance, with
          `datemin="04/23/1998"' and `dateformat="m/d/Y"', the first
          observation is assumed to be made the 23th April 1998. In R,
          it can also be a POSIXt date (see `?DataTimeClasses'). In
          this case, `dateformat' is not required and is ignored. By
          default, `datemin=NULL' 

dateformat: The format used for the date in `datemin'. For instance,
          `"d/m/Y"' or `"m/d/y"'. The distinction between "Y" and "y"
          is not important in Splus, but it is vital in R to use "y"
          for two-digit years (ex: 89) and "Y" for four-digits years
          (ex: 1989), or the date will not be correctly converted! In
          R, you can also use a POSIXt format specification like
          "%d-%m%Y" for instance (see `?strptime' for a complete
          description of POSIXt format specification. In both Splus and
          R, you can also use "mon" for abbreviated months like "mon d
          Y" for "Apr 20 1965", and "month" for fully-spelled months
          like "d month Y" for "24 September 2003" 

    xmin: The minimum value for the "days" time-scale 

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

     The "years" time-scale uses one unit for each year. We
     deliberately "linearized" time in this time-scale and each year
     has 365.25 days. There is thus no adjustment for bissextile years.
     Similarly, one month is considered to be 1/12 year, no mather if
     it has 28, 29, 30 or 31 days. This representation simplifies
     further calculations, especially regarding seasonal effects (a
     quarter is exactly 0.25 units for instance), but introduces some
     shifts in time (of up to one day, which is not significant when
     working on long-term series with years as units). However,
     converting it back to "days", using `yearstodays()' restablishes
     correct initial days without errors.

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

     A numerical vector of the same length as `x' with the converted
     time-scale

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

     Philippe Grosjean (phgrosjean@sciviews.org), Frdric Ibanez
     (ibanez@obs-vlfr.fr)

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

     `buysbal'

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

     # A vector with a "days" time-scale (25 values every 30 days)
     A <- (1:25)*30
     # Convert it to a "years" time-scale, using 23/05/2001 (d/m/Y) as first value
     B <- daystoyears(A, datemin="23/05/2001", dateformat="d/m/Y")
     B
     # Convert it back to "days" time-scale
     yearstodays(B, xmin=30)

