ibm - Standard cov() function in R not working in DSX -
the standard covariance function in r cov() not working in dsx.
i ran following code on states.x77 dataset:
cov(states)
i got following error message:
error in (function (classes, fdef, mtable) : unable find inherited method function ‘cov’ 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 find inherited method function %s signature %s", . squote(fdef@generic), squote(cnames)), domain = na) . } . else stop("internal error in finding inherited methods; didn't return 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 'cov' (no default method)", . domain = na))(x, ...), class = structure("nonstandardgenericfunction", package = "methods")), . <environment>) 3. stop(gettextf("unable find inherited method function %s signature %s", . squote(fdef@generic), squote(cnames)), domain = na)
i not sure doing wrong. turns out, stats::cov() overwritten sparkr::cov(). once replaced code with:
stats::cov()
the function returned desired result.
thanks, venky
cov()
in r comes stats
package. in r, order of importing libraries important , overwrite each others functions. seems case here. can call overwritten functions other packages specifying package name, as:
stats::cov(<dataset>)
Comments
Post a Comment