[R] S4 object slot of type 'call'
Seth Falcon
sfalcon at fhcrc.org
Tue May 29 04:53:53 CEST 2007
Roberto Brunelli <brunelli at itc.it> writes:
> I'm using an S4 object with a slot of type 'call': I would like to
> be able to initialize it with something like NULL or NA (indicating
> that there is no information in the slot) but the value should
> comply with the fact that it must be of type call.
>
> Is there any simple way to obtain this?
One possibility is to create a NullCall class:
setClass("NullCall", contains="call")
This can be put into a slot of type 'call' and identified by its
class. One advantage of this is that you can write a few methods for
NullCall and in many cases avoid explicit tests like:
if (class(obj) == "NullCall") ... else ...
For example, you could define a show metho that printed 'NULL' or
something.
It is also possible to define a class union and use that as the slot
type. I don't like this solution, but YMMV.
+ seth
--
Seth Falcon | Computational Biology | Fred Hutchinson Cancer Research Center
http://bioconductor.org
More information about the R-help
mailing list