Skip to content
Prev 316015 / 398513 Next

How to drop unused factors in faceted R ggplot boxplot?

Your example is not reproducible. [1]

Usually we use subset() or vector/array indexing when we want to work with part of the data. Apparently you want to exclude rows that specify "north" for which the year does not have a corresponding row with the same year and specifies "south".

southidxs <- with( test, "south" == site )
southyears <- unique( test$year[southidxs] )
subset( test, !("north"==site & !year %in% southyears ))

(untested)

[1] http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example
---------------------------------------------------------------------------
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.
Niec <ggorczynski at golder.com> wrote: