Skip to content
Back to formatted view

Raw Message

Message-ID: <CACuAxDkTbNw2=ZMVpLJ6Wwg9MuHcCNGDsRnT4FfkiPEumCuJqg@mail.gmail.com>
Date: 2013-03-17T20:36:55Z
From: David GarcĂ­a Callejas
Subject: [Rcpp-devel] nested lists into Rcpp

Hi all,

this is my first question here:

I have in R a list with several elements, some of them are lists, in the
vein of this:

mylist <- vector("list",10)
for(m in 1:10){
  mylist[[m]]$ID <- m
  mylist[[m]]$num <- vector("list",5)
  mylist[[m]]$num2 <- vector("list",5)
}

Is there a way to pass a data structure like this to a Rcpp function,
convert it to an appropriate C++ structure, and after doing some work with
it, return it in its original form?

fun <- cxxfunction(signature(x='List'), plugin='Rcpp', body = '
 using namespace std;
  List templist(x);
  //operations...
  return(wrap(templist));
   ')

Surely I am missing something obvious here, but I am just arrived to Rcpp,
and after looking in the documentation, I haven't found anything similar.
Thank you in advance
David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130317/8bb9f6ed/attachment.html>