Re: [R] adding bwplot to existing bwplot

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Fri, 28 Mar 2008 13:28:22 -0700

On 3/27/08, Karin Lagesen <karin.lagesen_at_medisin.uio.no> wrote:
>
>
> Hello.
>
> I have made many normal boxplots where I have added a new boxplot to
> an existing one. When I have done this, I have used the at command to
> move the boxplots a bit so that they could fit next to eachother, like
> this:
>
> boxplot(data......, at = number_of_categories-0.15)
> boxplot(data......, at = number_of_categoreis+0.15, add =TRUE)
>
> Now I am wondering if it is possible to do the same in some way with
> bwplot. The data I want to plot is like this:
>
> > operonthings[1:5,]
> phylum pid type no_clust no_seqs
> 1 Acidobacteria 15771 5S 1 1
> 2 Acidobacteria 12638 5S 1 2
> 3 Actinobacteria 16321 5S 2 6
> 4 Actinobacteria 92 5S 2 2
> 5 Actinobacteria 87 5S 1 5
> >
>
> where phylum and types are the factors I would like to plot no_clust
> and no_seqs against.I basically want these in the same plot:
>
> bwplot(no_clust~type|phylum, data = operonthings)
> and
> bwplot(no_seqs~type|phylum, data = operonthings)
>
> Any thoughts on how to do this?

One simple option is to have a conditioning variable distinguishing the two variables:

foo <-

    data.frame(x = gl(3, 1, 100),

               y1 = rnorm(100),
               y2 = runif(100))

bwplot(y1 + y2 ~ x, foo, outer = TRUE)

However, this will not put them side by side. To do that, you need to reshape the data, e.g., with

foo2 <- reshape(foo, direction = "long",

                varying = c("y1", "y2"),
                v.names = "y")

bwplot(y ~ factor(time) | x, foo2, layout = c(3, 1))

-Deepayan



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. Received on Fri 28 Mar 2008 - 20:32:51 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 28 Mar 2008 - 22:30:25 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive