<div dir="ltr">Hi Hadley,<div>Thank you for your prompt reply!<br><div><br></div><div>I understand your point, and am not sure how to proceed without it.</div><div><br></div><div><b><u>Motivation</u></b>: I'm currently working on my dendextend package (<a href="https://github.com/talgalili/dendextend">link to github</a>), and one of the biggest bottlenecks in working with dendrogram objects is the need to use recursion for various small tasks (using the dendrapply function).</div>

<div><b><u>Goal</u></b>: to be able to make specific dendrapply_Rcpp functions to make some operations faster.</div><div><br></div><div>If you think there is a better way, or that you still think I should not use it in this way (and generally, how to fix my the code from my previous post) - please let me know.</div>

<div><br></div><div>With regards,</div><div>Tal</div><div><br></div><div><br></div><div><br></div><div><br></div></div></div><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br>----------------Contact Details:-------------------------------------------------------<br>

Contact me: <a href="mailto:Tal.Galili@gmail.com" target="_blank">Tal.Galili@gmail.com</a> |  <br>Read me: <a href="http://www.talgalili.com" target="_blank">www.talgalili.com</a> (Hebrew) | <a href="http://www.biostatistics.co.il" target="_blank">www.biostatistics.co.il</a> (Hebrew) | <a href="http://www.r-statistics.com" target="_blank">www.r-statistics.com</a> (English)<br>

----------------------------------------------------------------------------------------------<br><br></div></div>
<br><br><div class="gmail_quote">On Fri, Jul 26, 2013 at 6:44 PM, Hadley Wickham <span dir="ltr"><<a href="mailto:h.wickham@gmail.com" target="_blank">h.wickham@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im">>             // note: The FUN will change the object x itself<br>
>             // hence - it must be clear to use an object we wish to change<br>
> (it will NOT be copied!)<br>
<br>
</div>Why do you want to do that?  It's a generally a bad idea to modify R<br>
objects in place.<br>
<br>
Here's a simple example showing why C level modification of R object<br>
is particularly dangerous:<br>
<br>
library(inline)<br>
foo <- cfunction(c(x = "SEXP"), '{<br>
  INTEGER(x)[0] = 0;<br>
  return R_NilValue;<br>
}')<br>
<br>
x <- 1:10<br>
y <- x<br>
foo(x)<br>
<br>
# First value is modified as expected<br>
x<br>
<br>
# But y is also modified!<br>
y<br>
<span class="HOEnZb"><font color="#888888"><br>
Hadley<br>
<br>
--<br>
Chief Scientist, RStudio<br>
<a href="http://had.co.nz/" target="_blank">http://had.co.nz/</a><br>
</font></span></blockquote></div><br></div>