Making R function recognize C function in same package?
c, r
Solution
My best guess: the package needs `useDynLib(<pkg_name>)` in its `NAMESPACE` file.
Problem
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?