[R] Object and Classes ?

myshare mraptor at gmail.com
Thu May 14 01:01:06 CEST 2009


I found a tutorial for creating classes using generic functions ? S3
way ! It was short description so I couldn't grok in full its
usage ... So far so good, what i currently do is something like this :

Blah <- function(data,...)  UseMethod('Blah')

Blah.default <- function( ...... ) {
   self = ....
   class(self) <- 'Blah'
   self

}

Blah.some_method <- function(self, .....) {
     self$abc ......and so on

}

My main "concerns" is now I have to call methods like this :

Blah.some_method(obj,.....)

isn't there some more shortcut syntax something along the lines
of  ;) :

obj.some_method(...)

Also if you can point me to some more documentation about using this
'generic function' design in R.
>From what I saw there is also some R.oo class for building OOP like
interface, but it seems even more
cumbersome to use.

Any link you can give me which discusses those concept in regards to
R, with examples too ;)
(Seems to me like a mix of javascript like prototyping with Perl bless
class name labeling,
like it much better than the rigid class oriented languages like Java ;) )

PS>
One of the biggest hurdles with R is that the language name is one
character long and when you try to find some
docs or solutions google returns alot of garbage not related to R ;)
Otherwise I like very much the environment and the capabilities of the
package, just that I'm pretty new with all statistics terminology and
help pages are made for ppl who
understand statistics, but anyway it is very valuable tool for learning.




More information about the R-help mailing list