[Rcpp-devel] max length of Rcpp::List is 20 elements?

Dirk Eddelbuettel edd at debian.org
Wed Oct 23 13:44:26 CEST 2013

Hi Florian,

On 21 October 2013 at 10:59, Florian Oswald wrote:
| I've noted that I cannot return an Rcpp::List longer than 20 elements. In
| particular, this here compiles:
| whereas it does not if you uncomment element "x20" with the error message 
| no matching function for call to ‘Rcpp::Vector<19>::create
| (Rcpp::traits::named_object<int>, ...
| from which I deduce that the Rcpp::List is an Rcpp::Vector of length 20. Was
| there any strong reason to stop at 20 elements?

Please see the list archives for a more extended discussion of this, it is a
known topic.

The short answer is: embed a list within a list, which you can recursively
to reach as many elements as you want, or until you run out memory.  

Expanding the list beyond 20 has cost in terms of autogenerated headers.

Hope this helps,  Dirk

Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com

More information about the Rcpp-devel mailing list