Romain,<br><br>many thanks for the (incredibly speedy) reply.<br><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
You are missing that :<br>
<br>
> typeof( 1:2 )<br>
[1] "integer"<br>
<br>
So as.double creates a new numeric vector, but:<br>
<br>
> typeof( 1 )<br>
[1] "double"<br>
<br>
So as.double just returns its input. as.double is a primitive function in R, so it does not really have pass by value semantics.<br></blockquote><div><br>Ok, I %really% should have picked up on that -- my R knowledge usually does stretch this far.<br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
By design, when you create an Rcpp object, you don't get a copy of the original object, you point to the same SEXP.</blockquote><div><br>Yup, I know that from the documentation.<br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
If you want a copy, you can use clone, as in :<br>
<br>
NumericVector vec = clone<NumericVector>(arg)<br></blockquote><div><br>This is a very interesting function (templated, I suppose) -- I haven't seen this in the examples/presentations. Thanks.<br><br>Incidentally, I have seen you now have a cheat sheet (or quick reference, as it's called on CRAN). I think this is very good idea for a certain group of users (like me -- those that want to get results relatively quickly without getting into %all% the nitty-gritty details), and it is worth keeping up to date. Clone as above for instance seems like a good candidate to add. Maybe the tex-source can even be put on some website (for personal additions/alterations)?<br>
<br>Best, Jo<br></div></div>