Leeds, Mark (IED) wrote:
I was reading a presentation of Professor Peng's and typed the
presentation code into R but I changed it to make plot.polygon a
separate function instread of defining the function in SetMethod itself
as he did. Is that the problem with the code below because
plot(p) just gives me zero. Thanks.
setClass(polygon, representation(x = numeric,
y = numeric))
plot - function(object)
{
return(0)
}
If you redefine plot this way, you cannot use a call to the generic plot
within the plot.polygon function any more.
Hence do *not* define the new plot() function above. The rest should work.
Uwe Ligges
setGeneric(plot)
plot.polygon - function(x, y, ...) {
xlim - range([EMAIL PROTECTED])
ylim - range([EMAIL PROTECTED])
plot(0,0, type = n, xlim = xlim, ylim = ylim, ...)
xp - c([EMAIL PROTECTED], [EMAIL PROTECTED])
yp - c([EMAIL PROTECTED], [EMAIL PROTECTED])
lines(xp, yp)
}
setMethod(plot,polygon,plot.polygon)
p - new(polygon, x = c(1,2,3,4), y = c(1,2,3,1))
plot(p)
This is not an offer (or solicitation of an offer) to buy/se...{{dropped}}
__
R-help@stat.math.ethz.ch 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.
__
R-help@stat.math.ethz.ch 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.