RcppDate                package:Rcpp                R Documentation

_C++ _c_l_a_s_s_e_s _f_o_r _r_e_c_e_i_v_i_n_g _d_a_t_e _a_n_d _d_a_t_e_t_i_m_e _R _o_b_j_e_c_t_s _i_n _C++

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

     'RcppDate', 'RcppDatetime', 'RcppDateVector' and
     'RcppDatetimeVector' are C++ classes defined in 'Rcpp.h' that can
     pass scalars and vectors of of R objects of types 'Date' and
     'POSIXct', respectively, to C++ via the '.Call()' function
     interface. 

     Member functions are provided to query the dimension of the vector
     or matrix object, convert it in a corresponding 'C'
     representation.

     R objects of type 'Date', and hence the 'RcppDate' and
     'RcppDateVector' objects, are internally represented as an integer
     counting days since the epoch, i.e. January 1, 1970. Similarly, R
     objects of type 'POSIXct' and the 'RcppDatetime' and
     'RcppDatetimeVector' objects, are internally represented as
     seconds since the epoch.  However, R extends the POSIX standard by
     using a double leading to microsecond precision in timestamps.
     This is fully supported by 'Rcpp' as well.

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

     Usage of the 'RcppDate', 'RcppDatetime' (and their vector
     extensions) in 'C++' is fully defined in 'Rcpp.h'. 

     As example, consider a call from R to 'C++' such as


       # an R example passing one type of each class to a function
       # someFunction in package somePackage
       val <- .Call("someFunction",
                    Sys.Date(),        # current date
                    Sys.time(),        # current timestamp
                    as.Date("2000-02-25")
                       + 0:5,         # date vector
                    ISOdatetime(1999,12,31,23,59,0)
                       + (0:5)*0.250, # datetime vector
                    PACKAGE="somePackage")

     At the 'C++' level, the corresponding code to assign these
     parameter to 'C++' objects is can be as follows::


       SEXP someFunction(SEXP ds, SEXP dts,
                         SEXP dvs, SEXP dtvs) {

         RcppDate           d(ds);                 
         RcppDatetime       dt(dts);
         RcppDateVector     dv(dvs);
         RcppDatetimeVector dtv(dtvs);
       }

     Standard accessor functions are defined, see 'Rcpp.h' for details.

     Objects of these types can also be returned via 'RcppResultSet'.

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

     Dominick Samperi wrote most of Rcpp during 2005 and 2006.  Dirk
     Eddelbuettel made some additions, and became maintainer in 2008.

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

     'RcppResultSet', the vignette "RcppAPI".

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

     # set up date and datetime vectors
     dvec <- Sys.Date() + -2:2
     dtvec <- Sys.time() + (-2:2)*0.5

     # call the underlying  C++ function
     result <- RcppDateExample(dvec, dtvec)

     # inspect returned object
     result

