I asked this a few days ago but without giving a reproducible example (sorry about that), so here I ask again with the actual code needed to reproduce it.
I currently have a nested list in Rcpp that is similar to what is generated here:
#include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
List listGenerate() {
List firstLayer(3);
List secondLayer(3);
for (int i=0; i<3; i++){
NumericVector myVec = NumericVector::create(1,2,3);
NumericMatrix myMat = cbind(myVec, myVec);
firstLayer(i) = myMat;
for (int j=0; j<3; j++){
secondLayer(j) = firstLayer;
}
}
return secondLayer;
}
This results in a nested list of matrices, which I would like to bind together by row. Normally in R one could do this to achieve that:
unlisted_first_layer <- unlist(listGenerate(), recursive = F)
do.call(rbind, unlisted_first_layer)
But I'm having trouble trying to do the same thing in Rcpp. Is there perhaps any syntactic sugar that might make this process a bit easier? Any help on this would be appreciated, thank you!