How to put values on boxplot and control its width?
X<-c(1,2,,3,4,4,5,5,6,6,6,6,6,7)
I need to write values for min, max, 1st quartile,
I had some problems trying to understand the boxplot quartiles labels and compare to summary function values, so i´d like to share with you.
Sometimes there will be differences in quartiles labels in boxplot using fivenum or stats comparing to r summary function values. This occurs only on even datasets.
e.g.(using text(x = boxplot.stats(X)$stats, labels = boxplot.stats(X)$stats, y = 1.25)):
product<-c(3,12,20,25,30,35,70,70,80,150)
summary(product)
Min. 1st Qu. Median Mean 3rd Qu. Max.
3.00 21.25 32.50 49.50 70.00 150.00
boxplot(product,horizontal=TRUE,col="grey",staplewex=1,axes=FALSE)
text(x = boxplot.stats(product)$stats, labels = boxplot.stats(product)$stats, y = 1.25)
BoxplotFiveNum
As you can see in the picture, the values do not match.
In this case you can use quantile function:
text(x=quantile(produto),labels=quantile(produto),y=1.25)
BoxplotQuantile
Now you should get the same values as listed on summary function. Otherwise just ignore summary function and use fiveNum values instead. The differences occurs due to lack of universal agreement among statisticians.
A google search will show you the differences on quantiles calculation.