String labels on boxplot outliers

Posted by Benoît Collette on Stack Overflow See other posts from Stack Overflow or by Benoît Collette
Published on 2010-05-11T17:41:56Z Indexed on 2010/05/11 17:44 UTC
Read the original article Hit count: 350

Filed under:
|
|
|

Hi!

I want to put string labels on outliers in a boxplot.

Here's a simplification of the dataset I'm using:

[,x]    [,y]    [,z]
7       2       a
10      2       b
112     3       c  

boxdata<-boxplot(x ~ y)

To put values as label on outliers by group, I use this function:

for(i in 1:length(boxdata$group)){

text(boxdata$group[i], boxdata$out[i], which(x==boxdata$out[i]),labels=boxdata$out[i],pos=4)

}

The problem is that I want to put z (string) as label instead of outlier value, but I don't know how to proceed. What do I need to do?

Thank you!
Ben

© Stack Overflow or respective owner

Related posts about boxplot

Related posts about outliers