I downloaded a .tgz file which contains R scripts in R/ and a single C file in src/.
An R function calls the C function in this way:
Mainfn<-function(x) {
output <- matrix(nrow(x),ncol(x));
output<-.C("myCfn",x=as.double(x),output=as.double(output),
PACKAGE='mypackage')
return(output)
}
In the C file, the function is defined this way [...] denotes a long series of computations.
#include <R.h>
#include <Rmath.h>
#include <math.h>
/*----------------------------------------------------------*/
void myCfn(double *x,double *output){
[...]
}
When I install the package with R CMD INSTALL mypackage.tgz, Mainfun() gives an error: "myCfn" not available for .C() for package "mypackage". I wonder how I can make my function recognize this function defined in the C file?
My best guess: the package needs useDynLib(<pkg_name>) in its NAMESPACE file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With