Hello, You seem to be confusing R namespaces and C++ namespaces and assuming you can call an R function as if it belonged to a C++ namespace. R functions and c++ functions are different things.
You can do something like: // get the spatstat environment Environment spatstat( "package:spatstat" ) ; // get the discpartarea function from that env Function discpartarea = spatstat["discpartarea"]; Then you can call discpartarea. Romain Le 11 juin 2014 à 19:01, mohammad ghorbani <ghorbani...@yahoo.com> a écrit : > Hi there, > > I would like to call discpartarea() and as.owin() functions of spatstat from > Rcpp. In a simple example > consider the following C++ code in which I'm trying to access the above > functions: > > #include <Rcpp.h> > using namespace Rcpp; > > // [[Rcpp::export]] > NumericVector IndepSelfCortCpp( NumericMatrix obsu) { > NumericMatrix obsxy = obsu( _ , Range(1,2) ) ; > NumericVector xyW= NumericVector::create(0,56,0,38); > double rslt = 0; > > rslt= spatstat::discpartarea(obsxy, 0.1, spatstat::as.owin(xyW)); > > return (rslt); > } > /* ** R > obsu <- matrix(c(0.5, 1.5, 4, 12, 1,2,3,4,2,3,5,7), ncol=3) > IndepSelfCortCpp(obsu) > */ > > When I source the file in Rstudio with sourceCpp(), I get the error: > " 'spatstat' has not been declard " > > I was wondering, a direct call a function of an R package like spatstat is > possible from Rcpp. > If yes, Could anyone help me on debugging the code? > > Best Regards, > Mohammad Ghorbani >
_______________________________________________ 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