[R] Splitting data in to multiple boxplots

Martyn Byng Martyn.Byng at nag.co.uk
Wed Sep 29 12:26:31 CEST 2010


Hi,

Something like

bb =
data.frame(label=c("a","b","a","b","c","a","b","c"),val=c(4,2,1,6,4,3,2,
1))
l = split(bb,bb$label)
par(mfrow=c(2,2))
lapply(l,function(a) {boxplot(a$val)})

might be what you are looking for

Martyn

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of deadlyspider
Sent: 29 September 2010 11:02
To: r-help at r-project.org
Subject: Re: [R] Splitting data in to multiple boxplots


Ok, I don't think I was specific enough.

The data originally came in this form


1  a  12
2  b  4
3  a  3
4  c  54
5  a  12
6  b  11
7  c  9
8  c  2
.  .  .
.  .  .
.  .  .



Where I sorted by the second column (NB the second column is the
categories
and they have long names). I would then like separate boxplots for each
category.

The loop idea would be nice but unfortunately I do not fully understand
the
answer given.

Thanks.
-- 
View this message in context:
http://r.789695.n4.nabble.com/Splitting-data-in-to-multiple-boxplots-tp2
717491p2718659.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star.\ _...{{dropped:12}}



More information about the R-help mailing list