Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Labeling outliers on boxplot in R

I would like to plot each column of a matrix as a boxplot and then label the outliers in each boxplot as the row name they belong to in the matrix. To use an example:

vv=matrix(c(1,2,3,4,8,15,30),nrow=7,ncol=4,byrow=F)
rownames(vv)=c("one","two","three","four","five","six","seven")
boxplot(vv)

I would like to label the outlier in each plot (in this case 30) as the row name it belongs to, so in this case 30 belongs to row 7. Is there an easy way to do this? I have seen similar questions to this asked but none seemed to have worked the way I want it to.

like image 796
user1836894 Avatar asked Mar 03 '13 00:03

user1836894


People also ask

Does R boxplot show outliers?

boxplot() does not identify outliers, but it is quite easy to program, as boxplot. stats() supplies a list of outliers.. You can add a density plot (barcode plot) to the boxplot.

How do you show outliers in a boxplot?

When reviewing a box plot, an outlier is defined as a data point that is located outside the whiskers of the box plot. For example, outside 1.5 times the interquartile range above the upper quartile and below the lower quartile (Q1 - 1.5 * IQR or Q3 + 1.5 * IQR).

How do you highlight outliers in R?

To highlight outliers in a boxplot, we can create the boxplot with the help of Boxplot function of car package by defining the id.

How do you label box plots?

Labels are used in box plot which are help to represent the data distribution based upon the mean, median and variance of the data set. R boxplot labels are generally assigned to the x-axis and y-axis of the boxplot diagram to add more meaning to the boxplot.


1 Answers

There is a simple way. Note that b in Boxplot in following lines is a capital letter.

library(car)

Boxplot(y ~ x, id.method="y")
like image 98
user4168562 Avatar answered Oct 16 '22 23:10

user4168562