[Rcpp-devel] Limit of 20 on length of Rcpp::List::create?
Tama Ma
pingnang at phys.ethz.ch
Tue Nov 1 22:04:01 CET 2011
Hi,
I recommend the following workaround instead...
std::vector<some_type> _your_favorite_list;
_your_favourite_list.push_back(_whatever_);
_your_favourite_list.push_back(_whatever_);
_your_favourite_list.push_back(_whatever_);
_your_favourite_list.push_back(_whatever_);
_your_favourite_list.push_back(_whatever_);
Rcpp::List = Rcpp::as<std::vector<some_type> >(_your_favourite_list);
Best regards,
Tama Ma
On Nov 1, 2011, at 9:32 PM, Michael Hannon wrote:
>
>
> Greetings. It appears that there is a limit of 20 items in a list created by;
>
> Rcpp::List:create
>
> I.e., the appended code works as expected if I omit all references to "x21",
> but fails with an error (shown below, after the code example) when I include
> "x21". (The successful output shown below is, obviously, for the case in
> which "x21" was NOT included.)
>
> A workaround appears to be just to pack the items into sublists and return the
> sublists. I just want to be sure I've understood correctly.
>
> Thanks,
>
> -- Mike
>
>
> #+BABEL: :session *R* :cache yes :results output verbatim :exports both :tangle yes
>
> * Return a long list
>
> #+begin_src R
> library(Rcpp)
> library(inline)
>
> includes = '
> '
>
> ccode = '
> int x1 (1);
> int x2 (2);
> int x3 (3);
> int x4 (4);
> int x5 (5);
> int x6 (6);
> int x7 (7);
> int x8 (8);
> int x9 (9);
> int x10 (10);
> int x11 (11);
> int x12 (12);
> int x13 (13);
> int x14 (14);
> int x15 (15);
> int x16 (16);
> int x17 (17);
> int x18 (18);
> int x19 (19);
> int x20 (20);
> int x21 (21);
>
> return (Rcpp::List::create(
> Rcpp::Named("x1") = x1,
> Rcpp::Named("x2") = x2,
> Rcpp::Named("x3") = x3,
> Rcpp::Named("x4") = x4,
> Rcpp::Named("x5") = x5,
> Rcpp::Named("x6") = x6,
> Rcpp::Named("x7") = x7,
> Rcpp::Named("x8") = x8,
> Rcpp::Named("x9") = x9,
> Rcpp::Named("x10") = x10,
> Rcpp::Named("x11") = x11,
> Rcpp::Named("x12") = x12,
> Rcpp::Named("x13") = x13,
> Rcpp::Named("x14") = x14,
> Rcpp::Named("x15") = x15,
> Rcpp::Named("x16") = x16,
> Rcpp::Named("x17") = x17,
> Rcpp::Named("x18") = x18,
> Rcpp::Named("x19") = x19,
> Rcpp::Named("x20") = x20,
> Rcpp::Named("x21") = x21
> )
> );
> '
> fn = cxxfunction(
> sig = signature(),
> body = ccode,
> includes = includes,
> plugin = "Rcpp")
>
> fn()
>
> #+end_src
>
> #+results[0bbf13bdc92f7b08c3d0922279abf8d31332c7e0]:
> #+begin_example
> $x1
> [1] 1
>
> $x2
> [1] 2
>
> $x3
> [1] 3
>
> $x4
> [1] 4
>
> $x5
> [1] 5
>
> $x6
> [1] 6
>
> $x7
> [1] 7
>
> $x8
> [1] 8
>
> $x9
> [1] 9
>
> $x10
> [1] 10
>
> $x11
> [1] 11
>
> $x12
> [1] 12
>
> $x13
> [1] 13
>
> $x14
> [1] 14
>
> $x15
> [1] 15
>
> $x16
> [1] 16
>
> $x17
> [1] 17
>
> $x18
> [1] 18
>
> $x19
> [1] 19
>
> $x20
> [1] 20
> #+end_example
>
> -----
>
> Error in compileCode(f, code, language = language, verbose = verbose) :
> Compilation ERROR, function(s)/method(s) not created! file1a507fc6.cpp: In
> function ‘SEXPREC* file1a507fc6()’:
> file1a507fc6.cpp:76:17: error: no matching function for call to
> ‘Rcpp::Vector<19>::create(Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>,
> Rcpp::traits::named_object<int>, Rcpp::traits::named_object<int>)’
> file1a507fc6.cpp:76:17: note: candidates are:
> /usr/lib64/R/library/Rcpp/include/Rcpp/ve
> In addition: Warning message:
> running command '/usr/lib64/R/bin/R CMD SHLIB file1a507fc6.cpp 2>
> file1a507fc6.cpp.err.txt' had status 1
>
>
> ------
>
>> sessionInfo()
> R version 2.13.1 (2011-07-08)
> Platform: x86_64-redhat-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
> [4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=C
> LC_MESSAGES=en_US.UTF-8
> [7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C
> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices datasets utils methods base
>>
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Best regards,
Tama Ma
(+41 78 640 50 15)
pingnang at phys.ethz.ch
www.phys.ethz.ch/~pingnang
HIT K 31.3
Institut für Theoretische Physik
Wolfgang-Pauli-Strasse 27
ETH Hönggerberg
8093 Zürich
Switzerland
More information about the Rcpp-devel
mailing list