[Rcpp-devel] Feedining an IntegerVector into Rcout?

Dirk Eddelbuettel edd at debian.org
Sat Nov 17 01:16:09 CET 2012

On 16 November 2012 at 23:28, Søren Højsgaard wrote:
| 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

As Romain said, it is simply not there. You need to define an operator<< for
this which we don;t have --- an easy avenue for someone to contribute
something meaningful but not too complicated (hopefully...).

What I do is to use Armadillo's containers -- they have this and a few other
input / output facilities.
| - 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)? 

a) Define a print function, or b) define operator<<, or c) cast to arma::vec
and print that or d) use the kludge of printing via a loop.


Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  

More information about the Rcpp-devel mailing list