[R] How to tell if lattice is current device?
Dieter Menne
dieter.menne at menne-biomed.de
Thu Feb 12 08:51:57 CET 2009
Remko Duursma <remkoduursma <at> gmail.com> writes:
> >> How can I tell if the current device was made with plot() or e.g.
> >> levelplot() or another lattice function?
> >> dev.cur() does not help me, it just tells me "windows 2".
> >
Deepayan:
> > A device can have both types, although that's rare.
> >
> > The best you can probably do is keep track of the last call to
> > plot.new() and grid.newpage(). See
> >
> > ?setHook
> > ?plot.new
> > ?grid.newpage
> >
Dieter:
library(lattice)
isStandard = function()
{
options(graphics="standard")
}
isLattice = function()
{
options(graphics="lattice")
}
setHook("plot.new",isStandard)
setHook("grid.newpage",isLattice)
xyplot(1~1)
options("graphics")
plot(1,1)
options("graphics")
More information about the R-help
mailing list