Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Create a new Rcpp::DateVector using given dates as string

$
0
0

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));

Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>