<div dir="ltr">Dear Dirk, Romain, Kevin, and others.<div><br></div><div>Since I am currently actively working on extending the dendrogram object in R, I have a real interest in finding and solving some of the major bottlenecks of dendrogram manipulation.</div>

<div>Thank you all for all of your help and suggestions thus far.</div><div><br></div><div>I took the liberty of starting a github repo for a new R package "RcppDend", you can see it here:</div><div><div><a href="https://github.com/talgalili/RcppDend">https://github.com/talgalili/RcppDend</a><br>

</div></div><div><br></div><div>It currently contains the function for label extraction from dendrogram (a mixture of the code Romain and Dirk wrote, with some minor modifications by me).</div><div>The Rcpp code is here:</div>

<div><a href="https://github.com/talgalili/RcppDend/blob/master/src/labels_dendrogram.cpp">https://github.com/talgalili/RcppDend/blob/master/src/labels_dendrogram.cpp</a><br></div><div>And the R code (wrapping it a bit, and adding documentation), is here:</div>

<div><a href="https://github.com/talgalili/RcppDend/blob/master/R/RcppDend.r">https://github.com/talgalili/RcppDend/blob/master/R/RcppDend.r</a><br></div><div><br></div><div>Currently, I can get the <span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre">labels.dendrogram</span> function to work when I'm compiling it in a local session, but <b><u>the function fails to work when loaded from this package</u></b>. If you have suggestions on how to fix it, I'd be happy to read.</div>

<div><br></div><div>And in general, I welcome any code contributions/commits.</div><div><br></div><div>Best,</div><div>Tal</div><div><br></div><div><br></div><div><br></div><div><br></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, Aug 16, 2013 at 9:04 PM, Kevin Ushey <span dir="ltr"><<a href="mailto:kevinushey@gmail.com" target="_blank">kevinushey@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 dir="ltr">Just a suggestion re: recursion with Rcpp, yet another nice way we can recurse is through using the sugar lapply:<br><br><div>-----</div><div class="im"><div><br></div><div>#include <Rcpp.h></div><div>

using namespace Rcpp;</div>
<div><br></div><div>// [[Rcpp::export]]</div></div><div>RObject add_attr(RObject x_) {</div><div>  RObject x = clone(x_);</div><div>  if (is<List>(x)) {</div><div>    x = wrap( lapply( as<List>(x), add_attr ) );</div>


<div>  } else {</div><div>    x.attr("type") = "Other";</div><div>  }</div><div>  return x;</div><div>}</div><div>  </div><div>/*** R</div><div>add_attr( list(x=list(a=1, b=2, c=3), y=list( list( d=4 ) ) ) )</div>


<div>*/</div><div><br></div><div>-----</div><div><br></div><div>If we want to operate on specific elements as well, we can use is<T> and as<T> together, and then operate on objects as needed.</div><div><br></div>


<div>It lets us avoid an explicit for loop, and 'feels' more like R.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>-Kevin</div></font></span></div>
</blockquote></div><br></div>