问题
I would appreciate if someone could help me in push_back a new component into DatetimeVector
. A DatetimeVector
only has begin, end, getDatetimes
and size methods.
回答1:
I'd say don't. For multiple reasons:
- All Rcpp types uses an underlying
SEXP
which requires contiguous memory. So adding a single element always requires copying all--expensive. - The
DatetimeVector
class is pretty bad. I wrote it many years ago to pass data to QuantLib. - These days we can do better via simple
NumericVector
classes toPOSIXct
-- see eg here in Rblpapi
来源:https://stackoverflow.com/questions/33794296/adding-a-new-component-to-a-datetimevector-in-rcpp