Flora Grappelli :
Is it possible to use an old version of the stats
package in R?
The function stats:::regularize.values
causes me warnings and errors in the last R version (any version >3.5).
I have no possibility to get back to an old R version.
I have no clue where the regularize.values
function is called in my code since I use several functions, some of them from different R packages.
I've tried to change the call to regularize.values
in my code by doing
assignInNamespace("regularize.values", regularize.values.old.version, ns = "stats")
But I got the error:
Error in assignInNamespace("regularize.values", regularize.values.OV, :
locked binding of ‘regularize.values’ cannot be changed
Thanks in advance for your suggestions!
Allan Cameron :
You can try this:
assignInNamespace("regularize.values", regularize.values.OV,
ns="stats", envir = as.environment("package:stats"))
However, it will only work if the error is not thrown by a package that depends on the already-loaded stats
Therefore, a working solution should be:
assignInNamespace("regularize.values", function(x, y, ties) {
x <- xy.coords(x, y)
y <- x$y
x <- x$x
if(any(na <- is.na(x) | is.na(y))) {
ok <- !na
x <- x[ok]
y <- y[ok]
}
nx <- length(x)
if (!identical(ties, "ordered")) {
o <- order(x)
x <- x[o]
y <- y[o]
if (length(ux <- unique(x)) < nx) {
# if (missing(ties))
# warning("collapsing to unique 'x' values")
y <- as.vector(tapply(y,match(x,x),ties))
x <- ux
stopifnot(length(y) == length(x))
}
}
list(x=x, y=y)
}, ns="stats", envir = as.environment("package:stats"))
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=368135&siteId=1