[R] termplot and ylim
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Jul 15 16:30:28 CEST 2006
It looks like a bug or at least an omission.
Try the following. It creates a new termplot function which
in turn defines a plot function which looks for a ylims= arg
and, if present, replaces the ylim= arg with ylims= and
then calls the real plot from the graphics package with the
new set of arguments.
It then defines a new proto object, i.e. an environment,
whose parent is the environment within the new termplot
we are setting up. It places a copy of termplot from the
stats package in that proto object naming the copy f.
This has the side effect of resetting f''s parent to
the proto object so that when f calls plot it finds
the plot we just defined instead of the usual plot.
Note that one uses ylims= instead of ylim in the call.
termplot <- function(...) {
plot <- function(...) { # replace ylim= with ylims=
args <- list(...)
if ("ylims" %in% names(args)) {
args$ylim <- args$ylims
args$ylims <- NULL
}
do.call(graphics::plot, args)
}
proto(f = stats::termplot)[["f"]](...)
}
# test
library(proto)
L <- lm(y ~ x, data.frame(x = 1:10, y = 10:1))
termplot(L, ylims = 1:2)
On 7/15/06, Andreas Beyerlein <AndiBuck at gmx.de> wrote:
> Hi together,
>
> I always get an error message with using ylim in termplot(), like this:
>
> > x<-(1:10)
> > y<-(10:1)
> > l<-lm(y~x)
> > termplot(l,ylim=c(1,2))
>
> Is this a bug, or is there another possibility to do that? Especially, I would like to use term.plot() for gamlss objects.
>
> Thanks for your help!
> Andreas
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
>
>
> Echte DSL-Flatrate dauerhaft für 0,- Euro*!
>
> ______________________________________________
> R-help at 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
>
More information about the R-help
mailing list