On 5 October 2012 at 21:39, Theodore Lytras wrote: | 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 ??
I've never tried this, but as Dates in R really are just integers since the epoch -- so maybe the NA_INTEGER aka R_NaInt will work? At a more conceptual level, NA shouldn't really be in dates, right? Either is a valid date, or it is missing (NULL). There simply is no such thing as Feb 30 or April 31. Dirk | Thank you in advance, | | Theodore Lytras | _______________________________________________ | Rcpp-devel mailing list | Rcpp-devel@lists.r-forge.r-project.org | https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel