[R] overloading "[" and "[<-" using S3 classes

Mark Heckmann mark.heckmann at gmx.de
Sat Oct 30 15:03:14 CEST 2010


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



More information about the R-help mailing list