TimeDateMathOps          package:fCalendar          R Documentation

_t_i_m_e_D_a_t_e _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:

     A collection and description of functions and methods for
     mathematical and logical operations on 'timeDate' objects. 

     The functions to perform mathematical operations:

       'Ops.timeDate'    Group 'Ops' generic functions for 'timeDate' objects,
       '+.timeDate'      Performs arithmetic + operation on 'timeDate' objects,
       '-.timeDate'      Performs arithmetic - operation on 'timeDate' objects,
       'diff.timeDate'   Returns suitably lagged and iterated differences,
       'difftimeDate'    Returns a difference of two 'timeDate' objects,
       'round.timeDate'  Rounds objects of class 'timeDate',
       'trunc.timeDate'  Truncates objects of class 'timeDate'.

     The functions to concatenate, sort and order 'timeDate' objects:

       'c.timeDate'       Concatenates 'timeDate' objects,
       'rep.timeDate'     Replicates a 'timeDate' object,
       'sort.timeDate'    Sorts a 'timeDate' object,
       'sample.timeDate'  Resamples a 'timeDate' object,
       'unique.timeDate'  NMakes a 'timeDate' object unique,
       'rev.timeDate'     Reverts  a 'timeDate' object.

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

     ## S3 method for class 'timeDate':
     Ops(e1, e2)
     ## S3 method for class 'timeDate':
     e1 + e2
     ## S3 method for class 'timeDate':
     e1 - e2
     ## S3 method for class 'timeDate':
     diff(x, lag = 1, differences = 1, ...)
     difftimeDate(time1, time2, 
         units = c("auto", "secs", "mins", "hours", "days", "weeks"))
     ## S3 method for class 'timeDate':
     round(x, units = c("days", "hours", "mins"), ...) 
     ## S3 method for class 'timeDate':
     trunc(x, units = c("days", "hours", "mins"), ...)     
         
     ## S3 method for class 'timeDate':
     c(..., recursive = FALSE)
     ## S3 method for class 'timeDate':
     rep(x, ...)
     ## S3 method for class 'timeDate':
     sample(x, ...)
     ## S3 method for class 'timeDate':
     sort(x, ...)
     ## S3 method for class 'timeDate':
     unique(x, ...)
     ## S3 method for class 'timeDate':
     rev(x)

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

differences: [lag] - 
           an integer indicating the order of the difference. 

  e1, e2: ["+"][["-"]["Ops"] - 
           usually objects of class 'timeDate', in the case of addition
          and subtraction 'e2' may be of class 'numeric'. 

     lag: [lag] - 
           an integer indicating which lag to use.   

  method: [modify] - 
           a character string defining the modification method, one of
          '"sort"', '"round"', or '"trunc"'.  

recursive: [c] - 
           a logical. If recursive  is set to 'TRUE', the function 
          recursively descends through lists combining all their
          elements  into a vector.  

time1, time2: [difftime] - 
           two objects objects of class 'timeDate'. 

   units: a character string denoting the date/time units in which the 
          results are desired. 

       x: [isWeekday][isWeekend][isBizday][weekDay] - 
           an object of class 'timeDate'. 
           [format][print] - 
           an object of class 'timeDate'. 

     ...: arguments passed to other methods. 

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

     'Ops.timeDate'
      '+.timeDate'
      '-.timeDate'
      'diff.timeDate'
      'difftimeDate'
      'round.timeDate'
      'trunc.timeDate' 
      these are functions for mathematical operations. Group code{Ops}
     are  generic functions which manage mathematical operations.  The
     plus operator '"+"' performs arithmetic "+" operation on 
     'timeDate' objects, and the minus operator '"-"' returns a 
     'difftime' object if both arguments 'e1' and 'e2'  are
     '"timeDate"' objects, or returns a '"timeDate"' object  'e2'
     seconds earlier than 'e1'. For the function, 'diff.timeDate', if
     'x' is a vector  of length 'n' and 'differences=1', then the
     computed result  is equal to the successive differences
     'x[(1+lag):n] - x[1:(n-lag)]'.  If 'difference' is larger than one
     this algorithm is applied recursively to 'x'. Note that the
     returned value is a vector  which is shorter than 'x'. The
     function, 'difftimeDate', takes a difference of two  'timeDate'
     objects and returns an object of class '"difftime"'  with an
     attribute indicating the units. The two functions 'round' and
     'trunc' allow to round or to  truncate '"timedate"' objects to the
     specified unit and return them as '"timedate"' objects. 

     'c'
      'rep'
      'sample'
      'sort'
      'unique'
      'rev' 
      these are functions to concatenate, to replicate, to resample, to
     sort, to make unique, and to revert 'timeDate' objects. The
     functions return an object of class '"timeDate"'.

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

     Diethelm Wuertz for the Rmetrics R-port.

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

     'timeDateClass', 'timeDateCoercion', 'timeDateSpecDates'

     We also recommend to inspect the help pages for the POSIX time and
     date  class, '?Dates', and the help pages from the contributed R
     packages 'chron' and 'date'.

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

     ## SOURCE("fCalendar.3C-TimeDateMathOps")   

     ## c -
        # Create Character Vectors:
        dts = c("1989-09-28", "2001-01-15", "2004-08-30", "1990-02-09")
        dts
        tms = c(  "23:12:55",   "10:34:02",   "08:30:00",   "11:18:23")
        tms
        
     ## "+/-" - 
        # Add One Day to a Given timeDate Object:
        GMT = timeDate(dts, zone = "GMT", FinCenter = "GMT")
        GMT
        ZUR = timeDate(dts, zone = "GMT", FinCenter = "Europe/Zurich")
        ZUR
        GMT + 24*3600
        ZUR[2] - ZUR[1]
       
     ## "[" - 
        # Subsets from and Lops for timeDate Objects:
        GMT[GMT < GMT[2]]
        ZUR[ZUR < ZUR[3]] == ZUR[1:3]

     ## diff - 
        # Suitably Lagged and Iterated Differences:
        diff(GMT)
        diff(GMT, lag = 2)
        diff(GMT, lag = 1, diff = 2)
        difftimeDate(GMT[1:2], GMT[-(1:2)])
        
     ## c | rep - 
        # Concatenate and Replicate timeDate Objects:
        c(GMT[1:2], ZUR[1:2])
        c(ZUR[1:2], GMT[1:2])
        rep(ZUR[2], times = 3)
        rep(ZUR[2:3], times = 2)  

