I want to use the npregbw
function from the np
package when developing my own Rcpp package.
Inspired by this, I created the following Rcpp function inside my package to make the call.
vec np_cv_bw(mat x, vec y){
Rcpp::Environment base("package:np");
Rcpp::Function npregbw = base["npregbw"];
List res= npregbw(Rcpp::_["xdat"] = x,
Rcpp::_["ydat"] = Rcpp::NumericVector(y.begin(), y.end()));
return as<vec>(res["bw"]);
}
However, I just realize that the above code cannot only work inside the R package environment. I got the following error
Cannot convert object to an environment: [type=character; target=ENVSXP]
My question is how I should modify the above function to make a call to an R function from another package in an Rcpp script for my own package?