Steve and Dirk, thanks again, I will look into the GenomicRanges package
 for my immediate usage, but for my future need, I will also keep trying
 to manipulate nested lists with Rcpp, as all my data structures are as 
such.<br><br><div class="gmail_quote">On Fri, Aug 12, 2011 at 4:37 PM, Dirk Eddelbuettel <span dir="ltr">&lt;<a href="mailto:edd@debian.org">edd@debian.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div><div></div><div class="h5"><br>
On 12 August 2011 at 16:26, Walrus Foolhill wrote:<br>
| Thanks for your advice, I now understand how to manipulate one-level lists:<br>
|<br>
| fn &lt;- cxxfunction(signature(l_in=&quot;list&quot;),<br>
|                   body=&#39;<br>
| using namespace Rcpp;<br>
| List l(l_in);<br>
| IntegerVector lf = l[&quot;foo&quot;];<br>
| CharacterVector lb = l[&quot;bar&quot;];<br>
| for(int i=0; i&lt;lf.size(); ++i)<br>
|   Rprintf(&quot;l[%s][%i] %i\\n&quot;, &quot;foo&quot;, i, lf[i]);<br>
| for(int i=0; i&lt;lb.size(); ++i)<br>
|   Rprintf(&quot;l[%s][%i] %s\\n&quot;, &quot;bar&quot;, i, std::string(lb[i]).c_str());<br>
| &#39;, plugin=&quot;Rcpp&quot;, verbose=TRUE)<br>
| z &lt;- fn(list(foo=c(1,2,3,4),bar=c(&quot;bar1&quot;,&quot;bar2&quot;)))<br>
|<br>
| But what about 2-level lists? Why the following code doesn&#39;t compile?<br>
|<br>
| fn &lt;- cxxfunction(signature(l_in=&quot;list&quot;),<br>
|                   body=&#39;<br>
| using namespace Rcpp;<br>
| List l(l_in);<br>
| List lf(l[&quot;foo&quot;]);<br>
| &#39;, plugin=&quot;Rcpp&quot;, verbose=TRUE)<br>
| z &lt;- fn(list(foo=list(bar=1)))<br>
|<br>
| And what the following message mean? &quot;error: call of overloaded ‘Vector<br>
| (Rcpp::internal::generic_name_proxy&lt;19&gt;)’ is ambiguous&quot;<br>
|<br>
| I had a look at &quot;runit.Vector.R&quot; on r-forge, but couldn&#39;t find any test<br>
| involving 2-level (or more) lists, although on SO in June 2010 (http://<br>
| <a href="http://stackoverflow.com/questions/3088650/how-do-i-create-a-list-of-vectors-in-rcpp/" target="_blank">stackoverflow.com/questions/3088650/how-do-i-create-a-list-of-vectors-in-rcpp/</a><br>
| 3088744#3088744), you said that it should work.<br>
|<br>
| I checked that I can create a 2-level list, but the code below doesn&#39;t compile<br>
| if I uncomment the last Rprintf line:<br>
<br>
</div></div>There can be times when the C++ templating gets in the way, so if this<br>
doesn&#39;t work in a single statement, decompose it into two (one to assign to a<br>
temp, another to print them temp) and move on.<br>
<br>
I have done two-level lists in the past; one key is that a list ... is just<br>
another SEXP, or can be wrap()&#39;ed to a SEXP, and you can hence assign a list<br>
to be a component of another. And then another and so on...<br>
<font color="#888888"><br>
Dirk<br>
</font><div><div></div><div class="h5"><br></div></div></blockquote></div>