<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello, </div><div><br></div><div>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. </div><div>R functions and c++ functions are different things. </div><div><br></div><div>You can do something like: </div><div><br></div><div>// get the spatstat environment</div><div>Environment spatstat( "package:spatstat" ) ;</div><div><br></div><div>// get the <span style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">discpartarea function from that env</span></div><div>Function <span style="font-size: 12pt; background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">discpartarea = </span>spatstat["<span style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">discpartarea</span>"];</div><div><br></div><div>Then you can call <span style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;">discpartarea. </span></div><div><br></div><div>Romain</div><br><div><div>Le 11 juin 2014 à 19:01, mohammad ghorbani <<a href="mailto:ghorbani_ms@yahoo.com">ghorbani_ms@yahoo.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div><div style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; position: static; z-index: auto;"><div style="" class="" id="yiv4776734297"><div style="" class=""><div class="" style="background-color: rgb(255, 255, 255); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12pt; position: static; z-index: auto;"><div style="" class="" id="yiv4776734297yui_3_16_0_1_1402502261301_11986">Hi there,</div><div style="" class="" id="yiv4776734297yui_3_16_0_8_1402502261301_8"><br style=""></div><div class="" style="font-size: 16px; font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: transparent; font-style: normal;">I would like to call discpartarea() and as.owin() functions of spatstat from Rcpp. In a simple example <br style="" class="">consider the following C++ code in which I'm trying to access the above
functions:<br style="" class=""><br style="" class="">#include <Rcpp.h><br style="" class="">using namespace Rcpp;<br style="" class=""><br style="" class="">// [[Rcpp::export]]<br style="" class="">NumericVector IndepSelfCortCpp( NumericMatrix obsu) {<br style="" class=""> NumericMatrix obsxy = obsu( _ , Range(1,2) ) ;<br style="" class=""> NumericVector xyW= NumericVector::create(0,56,0,38);<br style="" class=""> double rslt = 0; <br style="" class=""> <br style="" class=""> rslt= spatstat::discpartarea(obsxy, 0.1, spatstat::as.owin(xyW));<br style="" class=""> <br style="" class="">return (rslt);<br style="" class="">}<br style="" class="">/* ** R<br style="" class="">obsu <- matrix(c(0.5, 1.5, 4, 12, 1,2,3,4,2,3,5,7), ncol=3)<br style="" class="">IndepSelfCortCpp(obsu)<br style="" class="">*/<br style="" class=""><br style="" class=""><div style="" class="">When I
source the file in Rstudio with sourceCpp(), I get the error:</div>" 'spatstat' has not been declard "<br style="" class=""><br style="" class="">I was wondering, a direct call a function of an R package like spatstat is possible from Rcpp.<br style="" class="">If yes, Could anyone help me on debugging the code? <br><br>Best Regards,<br>Mohammad Ghorbani<br style="" class=""><br></div></div></div></div></div></div></blockquote></div></body></html>