This is not implemented. You can use Rf_PrintValue( out ) which prints just like R's print.

Le 17/11/12 00:28, Søren Højsgaard a écrit :
Dear list,

Sorry for a trivial question: I have created the function below which calls 
"match" on each vector in a list and returns the result as a list. The function 
does what I want it to, but I am puzzled by this:

+ IntegerVector out = R_match(wrap(ee), V_);
+ Rcout << out << std::endl;

which prints

0xca858e0
0xca85cd0
0xd715d80
0xd715db8

- which proves that there is something not clear to me: Can't I print an entire 
vector with Rcout - or must I exctract each element and print separately (which 
seems kludgy)?

Best regards
Søren



get_index_ <- cxxfunction(signature(x_ = "SEXP", V_="SEXP"), plugin = "Rcpp",
+ body = '
+     using namespace Rcpp;
+     using namespace std;
+ Function R_match("match");
+ CharacterVector V(V_);
+ List x(x_);
+ List res=List::create();
+ for (int ii=0; ii<x.length(); ii++){
+ CharacterVector ee = as<CharacterVector>(x[ii]);
+ IntegerVector out = R_match(wrap(ee), V_);
+ Rcout << out << std::endl;
+ res.push_back(out);
+ }
+ return(wrap(res));
+ ')

get_index_(list(c("a","b"),c("b","c"), c("a","c","e"), c("a","c","q")), 
letters[1:10])
0xca858e0
0xca85cd0
0xd715d80
0xd715db8
[[1]]
[1] 1 2

[[2]]
[1] 2 3

[[3]]
[1] 1 3 5

[[4]]
[1]  1  3 NA


--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30

R Graph Gallery: http://gallery.r-enthusiasts.com
`- http://bit.ly/SweN1Z : SuperStorm Sandy

blog:            http://romainfrancois.blog.free.fr
|- http://bit.ly/RE6sYH : OOP with Rcpp modules
`- http://bit.ly/Thw7IK : Rcpp modules more flexible

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to