[R] overlay of two sets of boxplots

Mirjam Appel appel at neuro.mpg.de
Mon Feb 20 19:59:49 CET 2012


Hello John,
Thanks for your fast answer. I will try to be clearer and more detailed this time. At the moment I am importing a dataframe like below as a '.csv file'. I want to generate a boxplot for M and F values grouped by X whereby boxplots for M and F should be above or very close to each other.  Please see attachment for example figure. Till now I have tried a code that looks like the one below the frame (I found it in the graph help of R for boxes close to each other):

X	M	                 F
Exp1	-90.0273224	-77.66531714
Exp1	-73.33333333	-96.36363636
Exp1	-98.24561404	-91.57848325
Exp1	-65.2173913	-59.18367347
Exp1	-98.7654321	-92.42424242
Exp1	-96.42857143	-89.25925926
Exp2	-84.61538462     -47.36842105
Exp2	-43.63636364     -22.37762238
Exp2	-47.5	               -33.33333333
Exp2	-55.49450549	-66.66666667

>boxplot(
    formula = F~Strain,
    data    = pain,
    boxwex  = 0.25,
    at      = 1:38 - 0.1,
    subset  =supp== "F",
    col     = "red",
    xlab    = "Strain",
    ylab    = " F"
   			 )
boxplot(
    formula = M~Strain,
    data    = pain,
    boxwex  = 0.25,
    at      = 1:38 + 0.1,
    subset  =supp== "M",
    col     = "orange",
    add     = TRUE )

...but I did cannot find anywhere what supp means and R cannot read it. 
I hope this is explained ok. Any kind of answer would help!
Best
Mirjam

-----Original Message-----
From: John Kane [mailto:jrkrideau at inbox.com] 
Sent: Monday, February 20, 2012 6:00 PM
To: Mirjam Appel; r-help at r-project.org
Subject: RE: [R] overlay of two sets of boxplots

PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

At a rough guess you may want to have a look at the mfrow in ?par  but without some sample data and a bit more information about what you need it is difficult to suggest more.

By the way dput (see ?dput) is a handy way to supply a sample data set here.

John Kane
Kingston ON Canada


> -----Original Message-----
> From: appel at neuro.mpg.de
> Sent: Mon, 20 Feb 2012 10:27:11 +0000
> To: r-help at r-project.org
> Subject: [R] overlay of two sets of boxplots
> 
> Hello,
> I am new to R and currently have the following problem:
> I have successfully loaded my data in R which consists of two numeric 
> columns (LI_F and female) and one character column (Strain). So far I 
> can plot two different set of boxplots for each of the numeric columns 
> plotted by the groups of the character column and the commands look 
> like
> that:
> 
> boxplot(LI_F~Strain, ylab="LI_F", xlab="Strain", data=pain) 
> boxplot(female~Strain, ylab="female", xlab="Strain", data=pain)
> 
> How can I overlay the two set of boxplots (preferably in different 
> colors), so that I can compare them one by one, meaning two boxplots 
> corresponding to the same character in "Strain" are directly above 
> each other?
> I have tried a lot of things and would greatly appreciate your help.
> 
> Best,
> Mirjam
> 
> 	[[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.

____________________________________________________________
Receive Notifications of Incoming Messages Easily monitor multiple email accounts & access them with a click.
Visit http://www.inbox.com/notifier and check it out!


-------------- next part --------------
A non-text attachment was scrubbed...
Name: overlayed boxplots.pdf
Type: application/pdf
Size: 9952 bytes
Desc: overlayed boxplots.pdf
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120220/9db85ae4/attachment.pdf>


More information about the R-help mailing list