[Rcpp-devel] How to create list of list without known structure

Florian Burkart florian.burkart at gmail.com
Tue May 6 14:35:53 CEST 2014


Perfect, thank you

On Tue, May 6, 2014 at 1:01 PM, Romain Francois <romain at r-enthusiasts.com>wrote:

>
> Le 6 mai 2014 à 09:35, Florian Burkart <florian.burkart at gmail.com> a
> écrit :
>
> > Hi,
> >
> > I have been creating lists of lists with
> >
> > return Rcpp::List::create(Rcpp::Named("vec") = someVector,
> >                           Rcpp::Named("lst") = someList,
> >                           Rcpp::Named("vec2") = someOtherVector);
> >
> > or to follow Romain:
> >
> > using namespace Rcpp ;
> > return List::create(
> >    _["vec"]  = someVector,
> >    _["lst"]  = someList,
> >    _["vec2"] = someOtherVector
> >  ) ;
> >
> > But how do I convert the following into a list of lists?
> >
> > std::vector<std::string> m_column_headers;
> > std::vector<std::vector<OptDouble> > m_vectors_of_values;
>
> You probably just need to know about .names() =, i.e. something like this
> should do:
>
> List values = wrap(m_vectors_of_values) ;
> values.names()  = m_column_headers ;
>
> FWIW, in Rcpp11, you could use structure, e.g. :
>
> List values = structure( m_vectors_of_values, _["names"] =
> m_column_headers ) ;
>
> Romain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140506/6e6f32ed/attachment.html>


More information about the Rcpp-devel mailing list