> Date: Mon, 23 May 2011 15:51:39 -0700
> From: ehl...@ucalgary.ca
> To: rashid...@hotmail.com
> CC: r-help@r-project.org
> Subject: Re: [R] Applying boxplot.stats to multiple value lists
>
> On 2011-05-23 07:40, Rashid Bakirov wrote:
> >
> > Hello all R gurus,
> >
> > I have a following problem which I hope someone will help me to solve.
> >
> > I have a data.frame in form similar to below.
>
> > testframe<-data.frame("Name"=c("aa","aa","aa","aa","aa","bb","bb","bb","bb","bb"),"Value"=c(1,100,1,1,1,100,100,100,100,1))
> > Name Value
> > 1 aa 1
> > 2 aa 100
> > 3 aa 1
> > 4 aa 1
> > 5 aa 1
> > 6 bb 100
> > 7 bb 100
> > 8 bb 100
> > 9 bb 100
> > 10 bb 1
> > > My aim is to find extreme upper whisker of boxplot
> (boxplot.stats$stats[5]) of Values
> > for each unique Name.I wrote the folowing function for this
> >
> > upex<-function(x){boxplot.stats(subset(testframe, Name==x,
> select=Value))$stats[5]}
> > When I test with different strings it works correctly> upex("bb")
> [... snip ...]
>
> Try the plyr package:
>
> require(plyr)
> ddply(testframe, .(Name), function(x) {
> boxplot.stats(x[["Value"]])[["stats"]][5]})
>
>
> Peter Ehlers
thanks Peter!
Using your suggestion I did the following to get what I want - merged original
data.frame with results of ddply(...)> merge(testframe, ddply(testframe,
.(Name), function(x) {boxplot.stats(x[["Value"]])[["stats"]][5]})) Name
Value V1
1 aa 1 1
2 aa 100 1
3 aa 1 1
4 aa 1 1
5 aa 1 1
6 bb 100 100
7 bb 100 100
8 bb 100 100
9 bb 100 100
10 bb 1 100
Rashid
[[alternative HTML version deleted]]
______________________________________________
R-help@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.