[R] labels outliers in boxplot

Greg Snow Greg.Snow at intermountainmail.org
Tue Jan 16 21:35:43 CET 2007


Some information on the outliers is returned from the boxplot function.  Try something like:

set.seed(123)
tmp <- data.frame( group=gl(3,10), 
  y=rcauchy(30), sex=gl(2,5,30,c('M','F')) )

tmp2 <- boxplot( split(tmp$y,tmp$group) )
identify( tmp2$group, tmp2$out, tmp2$group )

Or if your grouping variable works out to the same values as the x axis (used integers) and you want to specify a 3rd variable to be the labels you can do:

Identify( tmp$group, tmp$y, tmp$sex )

Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of 
> antoniababe at yahoo.se
> Sent: Wednesday, January 10, 2007 2:08 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] labels outliers in boxplot
> 
> Dear R-users,
> 
> Following is part of my data, where slide has 36 levels and 
> block 48 levels. I have done boxplot for each slide on the 
> same graph. There are outliers for each slide and I tried to 
> use indentify functtion to identify outliers in such a way 
> that when I click on an outlier or point, the points will be 
> labelled by either their block or ID or by both but without 
> success. How can I make it work or are there other ways to do 
> it than using identify function?
> 
> 
> Thanks in advance, 
> 
> Jenny,
> 
> dat1[1:10,]
>              y Slide Block              ID Control
> 1   0.03147823     1     1       IgG-human       5
> 2  -0.23815974     1     1 LPPAANDVSVLTAAR       0
> 3  -0.71926359     1     1 HTKHYRVVSKPAALV       0
> 4  -0.14607826     1     1 FVALPAATADAYATT       0
> 5   0.89553073     1     1 NYPAMMAHAGDMAGY       0
> 6  -0.67587100     1     1 RRALRQIGVLERPVG       0
> 7   0.32636034     1     1 DCGTIRVGSFRGRWL       0
> 8  -1.44057259     1     1 MAKLSTDELLDAFKE       0
> 9  -0.37064338     1     1 LELSDFVKKFEETFE       0
> 10 -0.20387233     1     1 VSRRAKVDVLIVHTT       0
> 
> 
>  tb_ncs<-subset(dat1,dat1$Control==1)     ### this
> data contains only negative controls
> 
>        par(las=2,mar=c(10.1,4.1,4.1,2.1)) 
>           
> boxplot(split(tb_ncs$y,tb_ncs$Slide),col="orange",
> cex=.65,
>                    outline=TRUE,main="Negative control 
> response of each patient", cex.main=1, font.main=1,
>                             col.main="blue",
> names=c(1:35,"B"))
>                    grid(nx=NA, ny=NULL)               
>           ### grid over boxplot 
>            legend("bottomright", "B = Buffer +
> sec",text.col="blue")
>                
> 
>             out.block<-
> identify(tb_ncs$y,tb_ncs$Slide) 
> 
> 
> 
> 	
> 	
> 		
> _________________________________________________________
> Flyger tiden iväg? Fånga dagen med Yahoo! Mails inbyggda
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>



More information about the R-help mailing list