GetUnitText             package:pastecs             R Documentation

_F_o_r_m_a_t _a _n_i_c_e _t_i_m_e _u_n_i_t_s _f_o_r _l_a_b_e_l_s _i_n _g_r_a_p_h_s

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

     This is an internal function called by some `plot()' methods.
     Considering the time series 'units' attribute and the frequency of
     the observations in the series, the function returns a string with
     a pertinent time unit. For instance, if the unit is 'years' and
     the frequency is 12, then data are monthly sampled and
     `GetUnitText()' returns the string "months"

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

     GetUnitText(series)

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

  series: a regular time series (a 'rts' object in Splus, or a 'ts'
          object in R) 

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

     a string with the best time unit for graphs

_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:

     `daystoyears', `yearstodays'

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

     timeser <- ts(1:24, frequency=12)           # 12 observations per year
     if (exists("is.R") && is.function(is.R) && is.R()) {  # We are in R
     attr(timeser, "units") <- "years"           # time in years for 'ts' object
     } else {                                              # We are in Splus
     attr(attr(timeser, "tspar"), "units") <- "years" # Idem for Splus 'rts' object
     }
     GetUnitText(timeser)                        # formats unit (1/12 year=months)

