[R] Applying boxplot.stats to multiple value lists

From: Rashid Bakirov <rashid719_at_hotmail.com>
Date: Mon, 23 May 2011 14:40:11 +0000

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")
[1] 100 > upex("aa")
[1] 1 But the problem is, how to apply this function to the whole dataframe at once, so I would get list of values as an output. As an output I want to to get values (1,1,1,1,1,100,100,100,100,100).I tried diffrent things such as> upex(testframe$Name)
[1] 100> lapply(testframe, upex)

$Name
[1] 100

$Value
[1] NA> for (x in testframe["Name"]) print(upex(x))
[1] 100 As you can see, I get only one value as an output, so I assume these calls apply the function to the whole set of values in the datframe. Is there a way to make it work as I want it to? I hope my question is understandable enough..

        [[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. Received on Mon 23 May 2011 - 17:35:04 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

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 Mon 23 May 2011 - 23:10:09 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