Skip to content
Prev 2106 / 10988 Next

[Rcpp-devel] data.frame from R to C++?

Should work as expected with the next version of Rcpp (svn version >= 
3000).

require( Rcpp )
require( inline )
df <- data.frame(
     V1 = c("c3", "c1", "c2" ),
     V2 = c("3a", "1b", "2c" )
     )
fx <- cxxfunction( signature( x = "data.frame" ), '
     DataFrame DF(x);
     StringVector v1 = DF["V1"];
     StringVector v2 = DF["V2"] ;
     return List::create( v1, v2) ;
' , plugin = "Rcpp" )


 > fx( df )
[[1]]
[1] "c3" "c1" "c2"

[[2]]
[1] "3a" "1b" "2c"

Romain


Le 12/04/11 12:38, deqiang sun a ?crit :