I am trying to concert a dataframe to a matrix in rcpp as in this answer: best way to convert DataFrame to Matrix in RCpp
NumericMatrix testDFtoNM(DataFrame x) {
NumericMatrix y = internal::convert_using_rfunction(x, "as.matrix");
return y;
}
and I get the error:
Line 135 reference to 'internal' is ambiguous.
This seems to indicate that there is more than one active namespace with internal as a definition.
How can I find the extra internal and/or how can I fix the code to compile without the error?
Update: Allan gave me the solution and using Rcpp::inline does allow it to work, but not why and how I can find the correct namespace on my own.
my current namespaces are:
using namespace Rcpp;
using namespace std;
using namespace arma;
using namespace RcppParallel;
Clearly internal exists in more than one of them. Is there a way to find which references have it without trial and error.
The function you are trying to call is in the internal
namespace which is nested inside the Rcpp
namespace as you can see in the docs. Presumably you are using at least two namespaces with a nested namespace called internal
. Therefore simply specifying
NumericMatrix testDFtoNM(DataFrame x) {
NumericMatrix y = Rcpp::internal::convert_using_rfunction(x, "as.matrix");
return y;
}
should resolve the ambiguity.