This works:

#include <Rcpp.h>
using namespace Rcpp;

// [[Rcpp::export]]
NumericVector fromList(List outer, std::string name) {
    return (as <List> (outer[0]) [name]);
}

/*** R
x <- c(0.2855202, 0.6731716, 0.8497825, 0.7445254, 0.2382722)
innL <- list(p=x)
outL <- list(List1=innL)
fromList(outL, "p")
*/

> sourceCpp("~/Desktop/dion.cpp")
> x <- c(0.2855202, 0.6731716, 0.8497825, 0.7445254, 0.2382722)
> innL <- list(p=x)
> outL <- list(List1=innL)
> fromList(outL, "p")
[1] 0.2855202 0.6731716 0.8497825 0.7445254 0.2382722
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to