R cov()中的標準協方差函數在DSX中不起作用。R中的標準cov()函數在DSX中不起作用
我跑了states.x77數據集下面的代碼:
cov(states)
,我得到了以下錯誤消息:
Error in (function (classes, fdef, mtable) : unable to find an
inherited method for function ‘cov’ for signature ‘"matrix"’
Traceback:
1. cov(states)
2. (function (classes, fdef, mtable)
. {
. methods <- .findInheritedMethods(classes, fdef, mtable)
. if (length(methods) == 1L)
. return(methods[[1L]])
. else if (length(methods) == 0L) {
. cnames <- paste0("\"", vapply(classes, as.character,
. ""), "\"", collapse = ", ")
. stop(gettextf("unable to find an inherited method for function %s
for signature %s",
. sQuote([email protected]), sQuote(cnames)), domain = NA)
. }
. else stop("Internal error in finding inherited methods; didn't
return a unique method",
. domain = NA)
. })(list("matrix"), structure(function (x, ...)
. {
. standardGeneric("cov")
. }, generic = structure("cov", package = "SparkR"), package =
"SparkR", group = list(), valueClass = character(0), signature =
"x", default = `\001NULL\001`, skeleton = (function (x,
. ...)
. stop("invalid call in method dispatch to 'cov' (no default
method)",
. domain = NA))(x, ...), class =
structure("nonstandardGenericFunction", package = "methods")),
. <environment>)
3. stop(gettextf("unable to find an inherited method for function
%s for signature %s",
. sQuote([email protected]), sQuote(cnames)), domain = NA)
我不知道我在做什麼錯。事實證明,stats :: cov()被SparkR :: cov()覆蓋。一旦我將我的代碼替換爲:
stats::cov()
函數返回了所需的結果。
謝謝, Venky
您是如何得到此錯誤的? – lebelinoz
我在states.x77數據集上運行了cov(states)。 stats :: cov(states)解決了這個問題。謝謝。 – Venky