How can I overload the "[" and "[<-" operators using S3 classes? Something like '['.{class} did not work or at least I do not know how to define it properly. For S4 it is straightforward: setMethod("[", signature(x = "myClass", i = "numeric"), function (x, i, j, ..., drop){ ... some operations }) How to do the same for S3? TIA! Mark ??????????????????????????????????????? Mark Heckmann Dipl. Wirt.-Ing. cand. Psych. Vorstra?e 93 B01 28359 Bremen Blog: www.markheckmann.de R-Blog: http://ryouready.wordpress.com
On Sat, Oct 30, 2010 at 9:03 AM, Mark Heckmann <mark.heckmann at gmx.de> wrote:> How can I overload the "[" and "[<-" operators using S3 classes? > Something like '['.{class} did not work or at least I do not know how to define it properly. > > > For S4 it is straightforward: > > setMethod("[", signature(x = "myClass", i = "numeric"), > ? ? ? ?function (x, i, j, ..., drop){ > ? ? ? ? ? ? ? ?... some operations > }) > > How to do the same for S3?Check out some examples by entering this into R: methods("[") # lists [ methods `[.data.frame` stats:::`[.ts` -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com
Maybe Matching Threads
- changing a list element's name during execution in lapply - possible?
- Reordering the results from table(cut()) by break argument
- RGtk2 / gWidgets - addHandlerClicked Problem
- gWidgets / RGtk2 - how to change a handler from a toolbar?
- how to flatten a list to the same level?