[Rd] inheritance and attach
Therneau, Terry M., Ph.D.
therne@u @end|ng |rom m@yo@edu
Mon Mar 15 19:19:42 CET 2021
This change in R-devel just bit me. Under the newest release, if I attach() another
.RData directory, the methods are not detected.
Was it intentional? Running in Linux. Here is a script of an example that works fine
under 3.6.2. but fails in R-devel.
tmt% mkdir temp1
tmt% cd temp1
tmt% R
# define a silly method, just for testing
charlie <- function(x, ...)
UseMethod("charlie")
charlie.default <- function(x, ...) {
cat("default method ", x, "\n")
x +2
}
charlie.character <- function(x, ...) {
cat("character method ", x, "\n")
as.character(as.numeric(x) + 2)
}
> quit("yes")
tmt% cd ..
tmt% R
> attach("temp1/.RData")
> charlie( 4)
Error in UseMethod("charlie") :
no applicable method for 'charlie' applied to an object of class "c('double', 'numeric')"
----------------------------------------
The use case was my local test environment for the survival package. I can work around it.
--
Terry M Therneau, PhD
Department of Health Science Research
Mayo Clinic
therneau using mayo.edu
"TERR-ree THUR-noh"
[[alternative HTML version deleted]]
More information about the R-devel
mailing list