On Jul 7, 2011, at 6:01 AM, Janko Thyson wrote:
Dear list,
In a function, I don't care if my input has class 'integer' or
'numeric', so I wanted to use 'inherits()' to control for that.
However, this function tells me that an actual object of class
'integer' does not inherit from class 'numeric'. The class def of
'integer' does state 'numeric' as one of the superclasses. Isn't
that somewhat inconsistent?
> getClass("integer")
Class "integer" [package "methods"]
No Slots, prototype of class "integer"
Extends: "numeric", "vector", "data.frameRowLabels"
> a <- 1:3
> class(a)
[1] "integer"
> inherits(a, "numeric")
[1] FALSE
> a <- 1:3
> is.numeric(a)
[1] TRUE
--
David Winsemius, MD
West Hartford, CT
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.