I'd like to do 'data.table-like' subsetting on `S4 class` by using 'i
expression'. However, '[' generic function has the problem to dispatch
S4 method because of its early evaluation of i argument.
e.g.
> gslist[Visit == 1, ]
Error in gslist[Visit == 1, ] :
error in evaluating the argument 'i' in selecting a method for
function '[': Error: object 'Visit' not found
Here 'gslist' is a S4 object `GatingSet` .
I wasn't able to bypass this even after I defined my own S3 method (e.g
[.GatingSet).
I guess it is because 'GatingSet' is S4 class and there are already some
S4 methods defined by other packages
> showMethods("[")
Function: [ (package base)
x="AnnotatedDataFrame", i="ANY"
x="flowFrame", i="ANY"
...
So it will always try these S4 methods before any S3 gets its chance.
Is there better way other than these two?
1. change 'GatingSet' to S3 class
2. use a different generic function that is not associated with any S4
methods (e.g. subset)
Mike
[Bioc-devel] a S4 dispatching question
5 messages · Gabriel Becker, Greg Finak, Mike
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/bioc-devel/attachments/20140806/03fe4805/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/bioc-devel/attachments/20140806/1ac0dfe3/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/bioc-devel/attachments/20140806/2df2ff47/attachment.pl>
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/bioc-devel/attachments/20140806/df6ad7dd/attachment.pl>