The following example, extracted from pp. 38-42 of Chambers (1998)
Programming with Data (Springer), works for me in S-Plus 6.2 but not R
1.9.0pat, which returns the indicated error messages:
> setClass('track', representation(x="numeric",
y="numeric"))
[1] "track"
> tr1 <- new("track", x=1:3, y=4:6)
> setMethod("plot",
+ signature(x="track", y="missing"),
+ function(x, y, ...)plot(x at x, x at y, ...)
+ )
[1] "plot"
> plot(tr1)
Error in plot.window(xlim, ylim, log, asp, ...) :
need finite xlim values
In addition: Warning messages:
1: no finite arguments to min; returning Inf
2: no finite arguments to max; returning -Inf
3: no finite arguments to min; returning Inf
4: no finite arguments to max; returning -Inf
Am I missing something or is my copy of R 1.9.0pat corrupted?
(This is under Windows 2000.)
Thanks Much!
Spencer Graves
>>>>> "Spencer" == Spencer Graves <spencer.graves at pdf.com> >>>>> on Wed, 02 Jun 2004 01:32:17 -0700 writes:Spencer> The following example, extracted from pp. 38-42 of Chambers (1998) Spencer> Programming with Data (Springer), works for me in S-Plus 6.2 but not R Spencer> 1.9.0pat, which returns the indicated error messages: >> setClass('track', representation(x="numeric", y="numeric")) Spencer> [1] "track" >> tr1 <- new("track", x=1:3, y=4:6) >> setMethod("plot", Spencer> + signature(x="track", y="missing"), Spencer> + function(x, y, ...)plot(x at x, x at y, ...) Spencer> + ) Spencer> [1] "plot" >> plot(tr1) Spencer> Error in plot.window(xlim, ylim, log, asp, ...) : Spencer> need finite xlim values Spencer> In addition: Warning messages: Spencer> 1: no finite arguments to min; returning Inf Spencer> 2: no finite arguments to max; returning -Inf Spencer> 3: no finite arguments to min; returning Inf Spencer> 4: no finite arguments to max; returning -Inf Spencer> Am I missing something or is my copy of R 1.9.0pat corrupted? Spencer> (This is under Windows 2000.) It works without a problem for me, both in R-1.9.0 or R-patched. Did you try these commands from a "freshly started" 'R --vanilla' ? {you will know how to do this ("R --vanila") in Windows ?} Martin
Dear Spencer,
I do not encounter any problem running your code in my machine. Maybe
is something wrong with your R installation!
setClass('track', representation(x="numeric",
y="numeric"))
tr1 <- new("track", x=1:3, y=4:6)
plot.track <- function(x, y, ...){
plot(x at x, x at y, xlab="x", ylab="y")
}
setMethod("plot", signature(x="track",
y="missing"), plot.track)
## or
setMethod("plot", signature(x="track",
y="missing"), function(x, y,
...) plot(x at x, x at x, ...))
## both work
plot(tr1)
Best,
Dimitris
----- Original Message -----
From: "Spencer Graves" <spencer.graves at pdf.com>
To: <r-help at stat.math.ethz.ch>
Sent: Wednesday, June 02, 2004 10:32 AM
Subject: [R] S4 classes?
> The following example, extracted from pp. 38-42 of Chambers
(1998)> Programming with Data (Springer), works for me in S-Plus 6.2 but not
R> 1.9.0pat, which returns the indicated error messages:
>
> > setClass('track', representation(x="numeric",
y="numeric"))
> [1] "track"
> > tr1 <- new("track", x=1:3, y=4:6)
> > setMethod("plot",
> + signature(x="track", y="missing"),
> + function(x, y, ...)plot(x at x, x at y, ...)
> + )
> [1] "plot"
> > plot(tr1)
> Error in plot.window(xlim, ylim, log, asp, ...) :
> need finite xlim values
> In addition: Warning messages:
> 1: no finite arguments to min; returning Inf
> 2: no finite arguments to max; returning -Inf
> 3: no finite arguments to min; returning Inf
> 4: no finite arguments to max; returning -Inf
>
> Am I missing something or is my copy of R 1.9.0pat corrupted?
> (This is under Windows 2000.)
>
> Thanks Much!
> Spencer Graves
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
Spencer Graves wrote:> The following example, extracted from pp. 38-42 of Chambers (1998) > Programming with Data (Springer), works for me in S-Plus 6.2 but not R > 1.9.0pat, which returns the indicated error messages: > > setClass('track', representation(x="numeric", y="numeric")) > [1] "track" > > tr1 <- new("track", x=1:3, y=4:6) > > setMethod("plot", > + signature(x="track", y="missing"), > + function(x, y, ...)plot(x at x, x at y, ...) > + ) > [1] "plot" > > plot(tr1) > Error in plot.window(xlim, ylim, log, asp, ...) : > need finite xlim values > In addition: Warning messages: > 1: no finite arguments to min; returning Inf > 2: no finite arguments to max; returning -Inf > 3: no finite arguments to min; returning Inf > 4: no finite arguments to max; returning -Inf > > Am I missing something or is my copy of R 1.9.0pat corrupted? > (This is under Windows 2000.) > Thanks Much! > Spencer GravesWorks for me with R-1.9.0 Patched (2004-05-24) Uwe