hi. below is a small test case (hopefully minimal, though i'm still a
bit confused about initializers).
i would have guessed (and maybe i still would have been right) that one
could re-use the name of a generic function for functions with different
numbers of arguments. in the case below, class A's bB() queries the
status of a single A object, so bB(A) (where here "A" is an instance of
class A, just for "clarity") returns a value. class B's bB() compares
values in two B objects, and returns the minimum, so bB(B1, B2) are its
methods.
after loading the file, i see the method for A's bB has disappeared (as
measured by showMethods("bB"), as well as trying bB(A). if i have R
re-parse the setGeneric/setMethod A's bB(), then B's bB() disappears.
somehow my code, or my model of how things work, is wrong. any ideas
what am i missing?
cheers, Greg Minshall
----
setClass("A",
representation(
x="numeric"));
setMethod(
f="initialize",
signature="A",
definition=function(.Object) {
.Object@x <- 23;
return(.Object)
});
setGeneric("bB", function(me) standardGeneric("bB"));
setMethod(
"bB",
signature("A"),
definition=function(me) {
return (new("B", me@x))});
setClass("B", representation(
bx="numeric"));
setMethod(
"initialize",
signature("B"),
definition=function(.Object, x) {
.Object@bx <- x;
return(.Object);
});
setGeneric("bB", function(b1, b2) standardGeneric("bB"));
setMethod(
"bB",
signature("B", "B"),
definition=function(b1, b2) {
return(new("B", min(b1@bx, b2@bx)))});
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.