aggregate-methods         package:timeSeries         R Documentation

_t_i_m_e_S_e_r_i_e_s _C_l_a_s_s, _F_u_n_c_t_i_o_n_s _a_n_d _M_e_t_h_o_d_s

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

     Aggregates a 'timeSeries' Object.

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

     ## S4 method for signature 'timeSeries':
     aggregate(x, by, FUN, ...)

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

      by: [aggregate] - 
           a character string denoting the aggregation period 

     FUN: the function to be applied. 

       x: an object of class 'timeSeries'. 

     ...: arguments passed to other methods. 

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

     returns an aggregated S4 object of class 'timeSeries'.

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

     ## data -
        x <- as.timeSeries(data(msft.dat))

     ## aggregate by weeks
        by <- timeSequence(from = start(x),  to = end(x), by = "week")
        aggregate(x, by, mean)

     ## aggregate to last Friday of month -
        by <- unique(timeLastNdayInMonth(time(x), 5))
        aggregate(x, by, mean)   

     ## aggregate to last day of quarter -
        by <- unique(timeLastDayInQuarter(time(x)))
        aggregate(x, by, mean)   

