[R] Multiple graphs > boxplot

David Winsemius dwinsemius at comcast.net
Fri Oct 5 18:51:44 CEST 2012

On Oct 5, 2012, at 9:01 AM, David Gramaje wrote:

> Dear all
> I am trying to represent a dependent variable (treatment) against different independent variables (v1, v2, v3....v20). I am using the following command:
> However, it provides me only one graph for v1~treatment. For the other comparisons, I have to repeat the same command but changing the parameters. My intentions is to get different plots in just one sheet using only one command. Is it possible to join the same order for all the comparisons in only one command?

Two options:
Melt the dataframe with reshape2::melt
then use boxplot( value ~ interaction(variable,treatment) )

Melt the dataframe
Use bwplot in lattice with a slightly more full featured formula interface

bwplot(value~cat|variable, data=amelt)

Option B is more beautiful in my opinion.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplot.pdf
Type: application/pdf
Size: 84789 bytes
Desc: not available
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20121005/85a6f90d/attachment-0002.pdf>
-------------- next part --------------


David Winsemius, MD
Alameda, CA, USA

More information about the R-help mailing list