Displaying 5 results from an estimated 5 matches for "maybenumb".
Did you mean:
maybenumber
2020 Sep 23
3
Is it possible to simply the use of NULL slots (or at least improve the help files)?
...slot
Again, maybe I missed it.
Even setClassUnion, which is what's used in the online examples,
doesn't contain a NULL slot example.
One more thing:
The help file for setClassUnion, uses the term "superclass", incorrectly.
Its examples include the following:
setClassUnion("maybeNumber", c("numeric", "logical"))
If maybeNumber was the superclass of numeric, then every instance of
numeric would also be an instance of maybeNumber...
2020 Sep 24
2
Is it possible to simply the use of NULL slots (or at least improve the help files)?
...ng, either.
Also, I'd recommend the S4 authors, go one step further.
Include character_OR_NULL, numeric_OR_NULL, etc, or something similar,
in S4's predefined basic classes.
Otherwise, contributed packages will (eventually) end up with hundreds
of copies of these.
> setClassUnion("maybeNumber", c("numeric", "logical"))
> every instance of numeric _is_ a maybeNumber, e.g.,
> > is(1, "maybeNumber")
> [1] TRUE
> which I think is consistent with the use of 'superclass'
Not quite.
x <- structure (sqrt (37), class = c (&quo...
2020 Sep 24
0
Is it possible to simply the use of NULL slots (or at least improve the help files)?
...should be or extend class "character_OR_NULL"
I understand there are situations where NULL is desired, perhaps to indicate 'not yet initialized' and distinct from character(0) or NA_character_, but want to mention those often appropriate alternatives.
With
setClassUnion("maybeNumber", c("numeric", "logical"))
every instance of numeric _is_ a maybeNumber, e.g.,
> is(1, "maybeNumber")
[1] TRUE
> is(1L, "maybeNumber")
[1] TRUE
> is(numeric(), "maybeNumber")
[1] TRUE
> is(NA_integer_, "maybeNumber")
[...
2020 Sep 24
0
Is it possible to simply the use of NULL slots (or at least improve the help files)?
...nderlying issues that I guess you are really after...
The S4 practice is to use setOldClass() to explicitly treat an S3 character() vector of classes as an assertion of linear inheritance
> x <- structure (sqrt (37), class = c ("sqrt.prime", "numeric") )
> is(x, "maybeNumber")
[1] FALSE
> setOldClass(class(x))
> is(x, "maybeNumber")
[1] TRUE
There are some quite amusing things that can go on with S3 classes, since the class attribute is just a character vector. So
> x <- structure ("September", class = c ("sqrt.prime",...
2003 Jul 24
0
Revisions of the S4 classes software + ?Documentation
...d explicitly with metadata objects (hopefully
not!) the changes should be largely compatible, but the point of this
mail is to alert owners of packages to watch for exceptions.
One known incompatibility has to do with setIs relations that extend the
basic datatypes. For example,
setClass("maybeNumber")
setIs("numeric", "maybeNumber")
setIs("logical", "maybeNumber")
defines a new class and says that "numeric" and "logical" extend it.
Once the new code is committed, this will fail, because the definition
of "numeric"...