Replacing slot of S4 class in method of S4 class?
Please read the posting guide and use the appropriate mailing list (R- help) - your question has nothing to do with the development of R. Cheers, Simon PS: look closely at your code - your mymethod is a noop.
On Mar 30, 2007, at 4:45 PM, cstrato wrote:
Dear all,
Assume that I have an S4 class "MyClass" with a slot "myname", which
is initialized to: myname="" in method("initialize"):
myclass <- new("MyClass", myname="")
Assume that class "MyClass" has a method "mymethod":
"mymethod.MyClass" <-
function(object, myname=character(0), ...) {
object at myname <- myname;
#or: myName(object) <- myname
}
setMethod("mymethod", "MyClass", mymethod.MyClass);
Furthermore, I have a replacement method:
setReplaceMethod("myName", signature(object="MyClass",
value="character"),
function(object, value) {
object at myname <- value;
return(object);
}
)
I know that it is possible to call:
myName(myclass) <- "newname"
However, I want to replace the value of slot "myname" for object
"myclass"
in method "mymethod":
mymethod(myclass, myname="newname")
Sorrowly, the above code in method "mymethod" does not work.
Is there a possibility to change the value of a slot in the method
of a
class?
Best regards
Christian
_._._._._._._._._._._._._._._._
C.h.i.s.t.i.a.n S.t.r.a.t.o.w.a
V.i.e.n.n.a A.u.s.t.r.i.a
_._._._._._._._._._._._._._._._
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel