[Rcpp-devel] Rcpp-devel Digest, Vol 12, Issue 8
On Fri, Oct 8, 2010 at 5:33 AM, Dirk Eddelbuettel <edd at debian.org> wrote:
On 8 October 2010 at 04:28, Christian Gunning wrote: | Yes, I've used this successfully. ?I have run into trouble extracting | elements of length>1 from lists with variable-length elements, e.g. | _mylist = list(a=1, b=1:3), mylist["a"] works but mylist["b"] is | squirrely. Please send a reproducible test case. ?I use the same approach a lot and have not had issues.
Ah. I see now that, in the example above, mylist["a"] is a 1-length NumericVector and (mylist["b"])[1] is a double. My confustion was using (mylist["b"])[1] in places that expected a NumericVector (like Rf_PrintValue() or return() ), or trying to pull the single element into a NumericVector: NumericVector i(mylist["b]); which, of course, initializes a NumericVector of length mylist["b"]. Thanks, Christian