Hello,
I know nothing about S7 classes but here are two notes.
(Inline)
Às 00:35 de 05/01/2026, Bert Gunter escreveu:
Could someone explain the following behavior to me, which I find
inconsistent and confusing:
inherits(1L, "integer")
[1] TRUE **as expected. S3 class**
inherits(1L, class_integer)
[1] TRUE ** as expected. S7 base class**
inherits(1.0, "double")
[1] FALSE ** There is no "double" class in S3
inherits(1.0, "numeric")
[1] TRUE ** doubles are S3 class "numeric". This is (sort of) documented**
BUT ...
inherits(1.0, class_double)
[1] FALSE ** because there is no S3 class "double" ?? **
I don't believe this is the reason why it's giving an error. The first
example in
vignette("classes-objects", package = "s7")
defines an new class Range with two properties, start and end, both of
class class_double.
inherits(1.0, class_numeric)
Error in inherits(1.2, class_numeric) :
'what' must be a character vector or an object with a nameOfClass() method
**class_numeric is an S7 union, not an S7 base class ?**
Apparently, 1.0 has no S7 class (?)
library(S7)
S7_class(1.0)
#> NULL
x <- 1.0
S7_class(x)
#> NULL
nameOfClass(x)
#> NULL
This is all I can say, I have no explanation nor solution.
Hope this helps,
Rui Barradas
So if 1.0 is not class_double, what base class is it? And how should I test
for the class of a non-integer numeric? And what is class_double then?
My apologies if this is obvious, but as I said, I find this confusing.
Best,
Bert
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.