[Rcpp-devel] Dynamic Wrapping and Recursion with Rcpp - using an R function?
Tal Galili
tal.galili at gmail.com
Fri Jul 26 17:59:46 CEST 2013
Hi Hadley,
Thank you for your prompt reply!
I understand your point, and am not sure how to proceed without it.
*Motivation*: I'm currently working on my dendextend package (link to
github<https://github.com/talgalili/dendextend>),
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).
*Goal*: to be able to make specific dendrapply_Rcpp functions to make some
operations faster.
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.
With regards,
Tal
----------------Contact
Details:-------------------------------------------------------
Contact me: Tal.Galili at gmail.com |
Read me: www.talgalili.com (Hebrew) | www.biostatistics.co.il (Hebrew) |
www.r-statistics.com (English)
----------------------------------------------------------------------------------------------
On Fri, Jul 26, 2013 at 6:44 PM, Hadley Wickham <h.wickham at gmail.com> wrote:
> > // note: The FUN will change the object x itself
> > // hence - it must be clear to use an object we wish to
> change
> > (it will NOT be copied!)
>
> Why do you want to do that? It's a generally a bad idea to modify R
> objects in place.
>
> Here's a simple example showing why C level modification of R object
> is particularly dangerous:
>
> library(inline)
> foo <- cfunction(c(x = "SEXP"), '{
> INTEGER(x)[0] = 0;
> return R_NilValue;
> }')
>
> x <- 1:10
> y <- x
> foo(x)
>
> # First value is modified as expected
> x
>
> # But y is also modified!
> y
>
> Hadley
>
> --
> Chief Scientist, RStudio
> http://had.co.nz/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130726/3ec4b9dd/attachment.html>
More information about the Rcpp-devel
mailing list