[Rcpp-devel] How to create list of list without known structure
Romain Francois
romain at r-enthusiasts.com
Tue May 6 13:01:40 CEST 2014
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
More information about the Rcpp-devel
mailing list