You could also define a replacement function and methods for it, when
test(testObj) <- 22
would change testObj itself. This is done via setReplaceMethod, but you
will need to look at Chambers (1998) to understand that, as
?setReplaceMethod leads to a page that does not describe it apart from
Again, R has a different paradigm from what you're used to. R is a
'pass by value' language. So 'obj' inside the method is a *copy* of
testObj, and your assignment changes the 'value' slot of the copy. An
R way of doing this might be
setMethod("test", signature=c("connect"),
function( obj ) {
Hi Martin
Thanks a lot for your short example. If you input
test(testObj)
it will return
22
However, how is it possible that the value will be saved in the object
i.e. (does not work currently!!??)
setMethod("test", signature=c("connect"),
function( obj ) { [EMAIL PROTECTED]<[EMAIL PROTECTE
The object paradigm in R is different; I like to think of methods as
orthogonal to classes, instead of nested within them.
Probably what you want to try is
# a generic function, to operate on different classes
setGeneric("test", function( obj ) standardGeneric( "test" ))
# a class, containing da
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:
---