this question has answer here:
i have package x
in r. package has function foo()
. want call function foo()
in cpp file (using rcpp). possible?
#include <rcpp.h> void function01() { // call foo() package x ?? }
this sort of duplicate. though, majority of cases not involve calling user defined package.
as result, mold use is:
#include <rcpp.h> using namespace rcpp; // [[rcpp::export]] void function01(){ // obtain environment containing function rcpp::environment package_env("package:package_name_here"); // make function callable c++ rcpp::function rfunction = package_env["function_name"]; // call function , receive output (might not list) rcpp::list test_out = rfunction(....); }
Comments
Post a Comment