1

I'm trying to pass a vector to the R function called from within Rcpp:

Rcpp::Function aperm("aperm");
int perm[3] = {2,1,3};
arr = aperm(arr, Rcpp::Named("perm", perm));

I've tried to wrap the perm before calling aperm but in both cases I am getting various Rcpp errors:

arr = aperm(arr, Rcpp::Named("perm", Rcpp::wrap(perm)));

Is it possible to pass a vector as a parameter to an R function when calling it from Rcpp?

Datageek
  • 25,977
  • 6
  • 66
  • 70

1 Answers1

4

Yes, it is but you need to make sure you use Rcpp::wrap() -- maybe explicitly if the implicit templated form is not called for you. Here, your C function array perm is of the wrong form. Make that an IntegerVector and things should work.

In general, complete and reproducible examples posted to the rcpp-devel list are the best way about this.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725