[Rd] methods::is problem in R 2.7.0 & R 2.8.0 devel
ml-it-r-devel at epigenomics.com
ml-it-r-devel at epigenomics.com
Wed Apr 16 14:29:46 CEST 2008
Hi,
x <- 1L
class(x) <- c("myInt", "integer")
is(x)
Error in inherits(x, "factor") :
argument "class2" is missing, with no default
The problem arises when is() is used with only one argument (object)
which has more than one class reported by class(object).
In the code is() does use variable "class2" before checking for its
presence.
Reversing the order of checks
is2 <- function(object, class2) {
cl <- class(object)
if (missing(class2))
return(extends(cl))
if (length(cl) > 1)
return(class2 %in% cl)
if (.identC(cl, class2) || .identC(class2, "ANY"))
return(TRUE)
ext <- possibleExtends(cl, class2)
if (is.logical(ext))
ext
else if (ext at simple)
TRUE
else ext at test(object)
}
is2(x)
[1] "myInt" "integer"
This is not sufficient, though:
utils::data(npk, package="MASS")
ret <- aov(yield ~ block + N*P*K, npk)
is2(ret)
[1] "aov" "lm" "lm" "mlm" "oldClass" "oldClass"
with duplicate class names
due to
extends(class(ret))
[1] "aov" "lm" "lm" "mlm" "oldClass" "oldClass"
so something different would be needed.
Best,
Matthias
> sessionInfo()
R version 2.7.0 RC (2008-04-15 r45347)
i686-pc-linux-gnu
locale:
LC_CTYPE=de_DE at euro;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=de_DE at euro;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE at euro;LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices datasets utils methods base
--
Matthias Burger Project Manager/ Biostatistician
Epigenomics AG Kleine Praesidentenstr. 1 10178 Berlin, Germany
phone:+49-30-24345-371 fax:+49-30-24345-555
http://www.epigenomics.com matthias.burger at epigenomics.com
--
Epigenomics AG Berlin Amtsgericht Charlottenburg HRB 75861
Vorstand: Geert Nygaard (CEO/Vorsitzender), Dr. Kurt Berlin (CSO)
Oliver Schacht PhD (CFO), Christian Piepenbrock (COO)
Aufsichtsrat: Prof. Dr. Dr. hc. Rolf Krebs (Chairman/Vorsitzender)
More information about the R-devel
mailing list