[Rcpp-devel] Rcpp::DataFrame

Romain Francois romain at r-enthusiasts.com
Mon Apr 26 09:19:50 CEST 2010


Hello,

I've commited some initial code for Rcpp::DataFrame. Interesting bits are:

DataFrame( SEXP ) ;

DataFrame::create( { between 0 and 20 arguments of whatever type wrap 
can handle } ) ;

So for example:

 > fx <- cppfunction( , '
+ std::vector<std::string> s(2) ;
+ s[0] = "hello";
+ s[1] = "world";
+
+ IntegerVector x = IntegerVector::create( 1, 2, 3, 4) ;
+
+ return DataFrame::create( _["x"] = x,  _["s"] = s );
+ ' )
 >
 > fx()
   x     s
1 1 hello
2 2 world
3 3 hello
4 4 world


The code of create first delegates to List::create and then calls the R 
function "as.data.frame", and an exception of type "not_compatible" is 
thrown if the call to as.data.frame fails.

Can anyone write some unit tests for it.

Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9aKDM9 : embed images in Rd documents
|- http://tr.im/OIXN : raster images and RImageJ
|- http://tr.im/OcQe : Rcpp 0.7.7



More information about the Rcpp-devel mailing list