<div dir="ltr"><div>Dear list members,</div><div><br></div><div>I would like to be able to get an element pushed with its attributes, and I came across the following problem:</div><div><br></div><div><div>cppFunction('</div>
<div>std::vector<List> temp(List x){</div><div> std::vector<List> lower;</div><div> lower.push_back(x);</div><div> return(lower) ;</div><div>}</div><div> ')</div><div>x = list(structure(1L, animal = "cat"))</div>
<div>temp(x)</div><div>temp(x[1])</div><div>temp(x[[1]]) # is there a way to not make this output without attributes?</div></div><div><br></div><div><br></div><div><br></div><div>If I use RObject, it will solve it, but then I would later not be able to iterate over the object, because I can't seem to get the .size() of an RObject.</div>
<div><br></div><div>Here is the code with the RObject:</div><div><div><br></div><div><br></div><div>cppFunction('</div><div>std::vector<RObject> temp2(RObject x){</div><div> std::vector<RObject> lower;</div>
<div> lower.push_back(x);</div><div> return(lower) ;</div><div>}</div><div> ')</div><div>x = list(structure(1L, animal = "cat"))</div><div>temp2(x)</div><div>temp2(x[1])</div><div>temp2(x[[1]]) # Now it works as I want, but the following wouldn't work:</div>
</div><div><br></div><div><br></div><div><br></div><div><div><br></div><div>cppFunction('</div><div>std::vector<RObject> temp2_fail(RObject x){</div><div> std::vector<RObject> lower;</div><div> int n x.size();</div>
<div> lower.push_back(x);</div><div> return(lower) ;</div><div>}</div><div> ')</div></div><div><br></div><div><br></div><div><br></div><div>Any ideas?</div><div><br></div><div><br></div><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>
</div>