yearmon                 package:zoo                 R Documentation

_A_n _I_n_d_e_x _C_l_a_s_s _f_o_r _M_o_n_t_h_l_y _D_a_t_a

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

     '"yearmon"' is a class for representing monthly data.

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

     yearmon(x)

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

       x: numeric (interpreted as being "in years").

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

     The yearmon class is used to represent monthly data. Internally it
     holds the data as year plus 0 for January, 1/12 for February, 2/12
     for March and so on in order that its internal representation is
     the same as  'ts' class with 'frequency = 12'. If 'x' is not in
     this format it is rounded via 'floor(12*x + .0001)/12'.

     There are coercion methods available for various classes
     including: default coercion to '"yearmon"' (which coerces to
     '"numeric"' first) and coercion from '"yearmon"' to '"Date"' (see
     below), '"POSIXct"', '"POSIXlt"', '"numeric"', '"character"'.

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

     Returns its argument converted to class 'yearmon'.

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

     'yearqtr', 'zoo', 'zooreg', 'ts'

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

     x <- yearmon(2000 + seq(0, 23)/12)
     x

     # returned Date is the fraction of the way through
     # the period given by frac (= 0 by default)
     as.Date(x)
     as.Date(x, frac = 1)
     as.POSIXct(x)

     z <- zoo(rnorm(24), x, frequency = 12)
     z
     as.ts(z)

