[R] Boxplots

William Dunlap wdunlap at tibco.com
Tue May 20 03:21:57 CEST 2014


Another method uses the core boxplot() function but replaces the usual
call to split() with a variant that puts all the data at the end of
the list of splits:

> splitPlusAll <- function(x, ...) c(split(x, ...), list(All=x))
> boxplot(with(mtcars, splitPlusAll(wt, list(gear,am), drop=TRUE)))
> boxplot(with(mtcars, split(wt, list(gear,am), drop=TRUE)))

(It helps if you show what you have done when your question arose, as
there are several R functions for drawing boxplots.)

Bill Dunlap
TIBCO Software
wdunlap tibco.com


On Mon, May 19, 2014 at 2:41 PM, Shane Carey <careyshan at gmail.com> wrote:
> Great,
>
> Thanks everyone :-)
>
> On Monday, May 19, 2014, Richard M. Heiberger <rmh at temple.edu> wrote:
>
>> tmp <- data.frame(y=c(rnorm(20), rnorm(20), c=rnorm(20)),
>> g=rep(letters[1:3], each=20))
>>
>> library(lattice)
>> library(latticeExtra)
>> A <- bwplot(y ~ g, data=tmp)
>> B <- bwplot(y ~ rep("Y",60), data=tmp, horizontal=FALSE)
>>
>> resizePanels(c(Individual=A, "All Together"=B, layout=c(2,1)), w=c(3,1))
>>
>>
>> ## for even more options, you can look at the examples in
>> ## the HH package
>> ## install.packages("HH") ## if necessary
>> library(HH)
>> demo("bwplot.examples", package="HH")
>> example("panel.bwplot.superpose", package="HH")
>> ?panel.bwplot.intermediate.hh
>> ?panel.bwplot.superpose
>>
>> On Mon, May 19, 2014 at 10:08 AM, Shane Carey <careyshan at gmail.com<javascript:;>>
>> wrote:
>> > Hi,
>> >
>> > I have boxplots by factors for a dataset and trying to include a boxplot
>> to
>> > represent the entire dataset.
>> >
>> > Any idea how this would be done?
>> >
>> > Thanks
>> >
>> > --
>> > Shane
>> >
>> >         [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > R-help at r-project.org <javascript:;> 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.
>>
>
>
> --
> Shane
>
>         [[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.



More information about the R-help mailing list