What is the appropriate way to use/convert named vectors in C++ with Rcpp. Basically I have a named vector of parameters that pass into the function. I cannot be certain of their order, so would like to extract them by name. For those initialized in C++ a std:map<std::string, double> should work, but how do declare one from a SEXP pointer that is passed in? For example:
draw <- cxxfunction(signature(A="numeric",t="numeric", params="numeric"),body=" SEXP draw( SEXP A, SEXP t, SEXP params){ Rcpp::NumericVector Admissions(A); Rcpp::NumericVector T(t); std::map<std::string, double> Params(params); std::vector<double> draws; for(int i=0;i<params[\"n\"];i++){ draws.pushback(rbinom(Admissions[T[i]+1,2], 1/(1+exp(-params[\"nu\"]))))); } return wrap(draws); } ",plugin='Rcpp') This of course does not compile because of std::map<std::string, double> Params(params); is not valid. But is shows more of less what I'm trying to do. Thanks, Andrew Redd _______________________________________________ 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