Hello all,<br><br>Still taking my first steps, I've come across a feature (?) I cannot yet make sense of. Consider a simple function with its argument passed by value:<br><br>SEXP fun(SEXP arg)<br>{<br><div style="margin-left: 40px;">
using namespace Rcpp;<br><br>NumericVector vec(arg);<br>for(int i=0; i<vec.size(); i++)<br>vec[i] += 1;<br><br>return vec;<br></div>}<br><br>The call in R is declared as<br><br>R.fun <- function(arg)<br>{<br><div style="margin-left: 40px;">
.Call( "fun", as.double(arg), PACKAGE = "wonderland" )<br></div>}<br><br><br>Using Rcpp 0.8.6 and R-2.11.1, I get<br><br>> arg <- 1:2 # or any vector of size > 1<br>> result <- R.fun(arg)<br>
> result; arg<br>[1] 2 3<br>[1] 1 2<br><br>That's fine -- but if I take as argument a vector of size 1, I get<br><br>> arg <- 1<br>> result <- R.fun(arg)<br>> result; arg<br>[1] 2<br>[1] 2<br><br>What am I missing?<br>
Thanks, Jo<br><br>