[R] Class & Method, S3 / S4
mailto-nik at bluemail.ch
mailto-nik at bluemail.ch
Wed Mar 1 13:45:24 CET 2006
Hi
I'm trying to create a class. However, I've some problems...
I am used to program php. There I can create a new object and call a specific
function of this object. In R, I hoped to create a class similar and then
call the function like:
Creating the Class:
<CODE>-----------------------------------
setClass("connect",
representation(test="function"))
)
setMethod("test", "connect",
function(value){
value /2
}
)
</CODE>-----------------------------------
testObj = new ("connect")
testObj at test(44)
That should return 22. However, unfortunately it does not work. How can I
solve this problem. I read several instructions, but how does R work???.
Does anybody have a very simple example like above.
I highly appreciate any help.
Thanks a lot.
Nik
More information about the R-help
mailing list