I was trying to analyse cor(stats) function but I stack on line containing first .Call function :
.Call(C_cor, x, y, na.method, FALSE)
C_cor
isn't defined before it is called, it isn't defined anywhere, how to execute above line outside the cor
function ? Setting y to NULL, na.method to everything, and x to some dataset brings the same object 'C_cor' not found error, part of cor() body below :
> cor
function (x, y = NULL, use = "everything", method = c("pearson",
"kendall", "spearman"))
{
na.method <- pmatch(use, c("all.obs", "complete.obs", "pairwise.complete.obs",
"everything", "na.or.complete"))
if (is.na(na.method))
stop("invalid 'use' argument")
method <- match.arg(method)
if (is.data.frame(y))
y <- as.matrix(y)
if (is.data.frame(x))
x <- as.matrix(x)
if (!is.matrix(x) && is.null(y))
stop("supply both 'x' and 'y' or a matrix-like 'x'")
if (!(is.numeric(x) || is.logical(x)))
stop("'x' must be numeric")
stopifnot(is.atomic(x))
if (!is.null(y)) {
if (!(is.numeric(y) || is.logical(y)))
stop("'y' must be numeric")
stopifnot(is.atomic(y))
}
Rank <- function(u) {
if (length(u) == 0L)
u
else if (is.matrix(u)) {
if (nrow(u) > 1L)
apply(u, 2L, rank, na.last = "keep")
else row(u)
}
else rank(u, na.last = "keep")
}
if (method == "pearson")
Call(C_cor, x, y, na.method, FALSE)
...
Edition example of use
you can call C_cor like below :
C_cor=get("C_cor", asNamespace("stats"))
.Call(C_cor, x=as.matrix(iris[,1:4]), y=NULL, method=1, FALSE
)
where method is number of method on this list :
c("all.obs", "complete.obs", "pairwise.complete.obs",
"everything", "na.or.complete")