On 6 October 2012 at 11:05, Dirk Eddelbuettel wrote:
| I had a look too. It is not as simple.

Actually, it was that simple.

And this is now taken care of in an interim version labelled 0.9.14.2 which
you'll find on my site in a moment, and via R-Forge once new tarballs are
built. Rcpp 0.9.15 will come shortly but there is something else I need to
post about first (maybe later today).

For the new date stuff, here is a teaser, using inline 0.3.10 with its new
rcpp() function:

  library(inline)

  f <- rcpp(signature(ds="numeric"), body='
     Rcpp::DateVector d(ds);
     return(d);
  ')

  v <- c(1,2,NA,777,NaN,-4,Inf,-4)  + as.numeric(Sys.Date())
  print(f(v))

which yields 

  edd@max:~/svn/rcpp/pkg$ r /tmp/dateNA.r 
  Loading required package: methods
  [1] "2012-10-07" "2012-10-08" NA           "2014-11-22" NA          
  [6] "2012-10-02" NA           "2012-10-02"
  edd@max:~/svn/rcpp/pkg$ 

as it should.  I added the same check to Datetime as well so for

  f <- rcpp(signature(ds="numeric"), body='
     Rcpp::DatetimeVector d(ds);
     return(d);
  ')

  v <- c(1,2,NA,777,NaN,-4,Inf,-4)  + as.numeric(Sys.time())
  print(f(v))

we get 

  edd@max:~/svn/rcpp/pkg$ r /tmp/dateNA.r 
  Loading required package: methods
  [1] "2012-10-06 12:03:44 CDT" "2012-10-06 12:03:45 CDT"
  [3] NA                        "2012-10-06 12:16:40 CDT"
  [5] NA                        "2012-10-06 12:03:39 CDT"
  [7] NA                        "2012-10-06 12:03:39 CDT"
  edd@max:~/svn/rcpp/pkg$ 


So my thanks to Theodore for (ever so gently) pushing for this. It's a useful
addition. 

Dirk


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

Reply via email to