How can I create a new DateVector
(a C++ class from the package Rcpp
) with dates given during compile time?
Since a DateVector
is an NumericVector
I can do this:
DateVector d = DateVector::create(14974, 14975, 15123); // TODO how to use real dates instead?
But I would prefer to use a more intuitive and human-readable representation like
DateVector d = DateVector::create("2010-12-31", "2011-01-01", "2011-05-29");
but this causes an compiler error like
Rcpp/include/Rcpp/vector/converter.h:34:27: error: no matching function for call to ‘caster::target>(const char [11])’ return caster(input) ;
Edit: I have found a working example (also showing some variations):
DateVector d = DateVector::create(Date("2010-12-31"), Date("01.01.2011", "%d.%m.%Y"), Date(2011, 05, 29));