I'm writing a new R function that uses a modified version of the cor
function (i.e. cor2), to do this I used the bare bone of the native cor function. In the original code is present a call to a C_cor
function in the package stats. I try to run the cor2 function but I get the following error:
Error: object 'C_cor' not found
.
I modified the call to the compiled function from
.Call(C_cor, x2, y2, 1L, method == 'kendall')
to
.Call(stats:::C_cor, x2, y2, 1L, method == 'kendall')
.
After that all works fine.
When I try the R CMD check
command to verify the package I'm working to, I get:
* checking dependencies in R code ... NOTE
Unexported object imported by a ':::' call: ‘stats:::C_cor’
See the note in ?`:::` about the use of this operator.
See the information on DESCRIPTION files in the chapter ‘Creating R
packages’ of the ‘Writing R Extensions’ manual.
and :
* checking foreign function calls ... WARNING
Foreign function call to a base package:
.Call(stats:::C_cor, ...)
Packages should not make .C/.Call/.External/.Fortran calls to a base
package. They are not part of the API, for use only by R itself and
subject to change without notice.
I read the 'Writing Extension' manual but I've not been able to solve the problem. I also tried to find the C_cor funcion in the stats package (from a fresh R download) as suggested by Uwe Ligge... I found the cov.c
function from within the cor
function is called... I think... I tried to copy the cov.c file and compile it but I get several errors:
:$ R CMD SHLIB cov.c gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -O2 -pipe -g -c cov.c -o cov.o cov.c:31:18: fatal error: Defn.h: No such file or directory compilation terminated. make: *** [cov.o] Error 1
I copied the Defn.h
file too but the error persist. I'm not expert in c
and I have not the idea how to overcome this problem.
Do you have any suggestion?
Indeed how can I overcome the NOTE and the WARNING from the R CMD check?
All the best