Dear all, In a plot command like xyplot(Y~X|ID*PERIOD,data=...) xyplot will generate all the possible ID*PERIOD combinations. But not all of them have data in there. So I have a lot of empty plots. How can I suppress those empty plots and ask xyplot only to generate plots actually with data. Thanks. Jun [[alternative HTML version deleted]]
Jeff Newmiller
2012-Feb-14 17:08 UTC
[R] How to suppress the empty plots in xyplot (lattice)
Set up a single (factor) variable that identifies the combinations that exist, and plot using that variable. --------------------------------------------------------------------------- Jeff Newmiller The ..... ..... Go Live... DCN:<jdnewmil at dcn.davis.ca.us> Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/Batteries O.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --------------------------------------------------------------------------- Sent from my phone. Please excuse my brevity. Jun Shen <jun.shen.ut at gmail.com> wrote:>Dear all, > >In a plot command like > >xyplot(Y~X|ID*PERIOD,data=...) > >xyplot will generate all the possible ID*PERIOD combinations. But not >all >of them have data in there. So I have a lot of empty plots. How can I >suppress those empty plots and ask xyplot only to generate plots >actually >with data. Thanks. > >Jun > > [[alternative HTML version deleted]] > >______________________________________________ >R-help at r-project.org 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.
> read ?xyplot > It takes a skip argument: > ? ? ? ? ??skip?: logical vector (default ?FALSE?), replicated to be as > ? ? ? ? ? ? ?long as the number of panels (spanning all pages). ?For > ? ? ? ? ? ? ?elements that are ?TRUE?, the corresponding panel > ? ? ? ? ? ? ?position is skipped; i.e., nothing is plotted in that > ? ? ? ? ? ? ?position. ?The panel that was supposed to be drawn there > ? ? ? ? ? ? ?is now drawn in the next available panel position, and > ? ? ? ? ? ? ?the positions of all the subsequent panels are bumped up > ? ? ? ? ? ? ?accordingly. ?This is often useful for arranging plots in > ? ? ? ? ? ? ?an informative manner. > > Or a 'drop.unused.levels' argument, or a 'subset'. > > Any one of these would work . > > Cheers > > On Tue, Feb 14, 2012 at 10:50 AM, Jun Shen <jun.shen.ut at gmail.com> wrote: >> Thanks, Jeff, >> >> It did work in one way if I use >> >> xyplot(Y~X|as.factor(ID*PERIOD),data=...) >> >> But I would like to do something like >> >> xyplot(Y~X|as.factor(paste("ID=",ID)*paste("PERIOD=",PERIOD)),data=...) >> >> Then, it didn't work >> >> The error message: >> Error in paste("ID=", ID) * paste("PERIOD=", PERIOD) : >> ?non-numeric argument to binary operator >> >> On Tue, Feb 14, 2012 at 11:08 AM, Jeff Newmiller >> <jdnewmil at dcn.davis.ca.us>wrote: >> >>> Set up a single (factor) variable that identifies the combinations that >>> exist, and plot using that variable. >>> --------------------------------------------------------------------------- >>> Jeff Newmiller ? ? ? ? ? ? ? ? ? ? ? ?The ? ? ..... ? ? ? ..... ?Go Live... >>> DCN:<jdnewmil at dcn.davis.ca.us> ? ? ? ?Basics: ##.#. ? ? ? ##.#. ?Live >>> Go... >>> ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Live: ? OO#.. Dead: OO#.. ?Playing >>> Research Engineer (Solar/Batteries ? ? ? ? ? ?O.O#. ? ? ? #.O#. ?with >>> /Software/Embedded Controllers) ? ? ? ? ? ? ? .OO#. ? ? ? .OO#. ?rocks...1k >>> --------------------------------------------------------------------------- >>> Sent from my phone. Please excuse my brevity. >>> >>> Jun Shen <jun.shen.ut at gmail.com> wrote: >>> >>> >Dear all, >>> > >>> >In a plot command like >>> > >>> >xyplot(Y~X|ID*PERIOD,data=...) >>> > >>> >xyplot will generate all the possible ID*PERIOD combinations. But not >>> >all >>> >of them have data in there. So I have a lot of empty plots. How can I >>> >suppress those empty plots and ask xyplot only to generate plots >>> >actually >>> >with data. Thanks. >>> > >>> >Jun >>> > >>> > ? ? ? [[alternative HTML version deleted]] >>> > >>> >______________________________________________ >>> >R-help at r-project.org 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. >>> >>> >> >> ? ? ? ?[[alternative HTML version deleted]] >> >> ______________________________________________ >> R-help at r-project.org 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.