[Rcpp-devel] NA value for dates
Theodore Lytras
thlytras at gmail.com
Fri Oct 5 20:39:02 CEST 2012
Hello all,
I am trying to pass from C++ to R a DateVector with a few missing items (NAs).
I can't seem to find a way, though.
There does not seem to be a NA_DATE (like NA_REAL, etc), and the default
constructor for Rcpp::Date creates a date of "-5877641-06-23".
I have even tried to pass an Rcpp::NumericVector and convert like this:
Rcpp::NumericVector a = Rcpp::NumericVector::create(3883, NA_REAL, 15120);
Rcpp::Language call("as.Date", a, Rcpp::Named("origin", "1970-1-1"));
Rcpp::DateVector b(3);
aa = call.eval();
but I still get "1980-08-19" "-5877641-06-23" "2011-05-26" .
The only way to get the expected output is by:
Rcpp::NumericVector a = Rcpp::NumericVector::create(3883, NA_REAL, 15120);
R["a"] = a;
R.parseEvalQ("aaa <- as.Date(a, origin=\"1970-1-1\")");
Isn't there any better way to specify a NA for dates, or check if an
Rcpp::Date is NA ??
Thank you in advance,
Theodore Lytras
More information about the Rcpp-devel
mailing list