Boxplot is an R function that represents a numeric vector of data that is split in several groups.
It can be usefull to specify a feature for each group. In this exemple, the number of vlues within each group is represented. Another utility could be to add the significance of a statistical test.
The trick is to use the text function, that permits to add text wherever in a R plot. For this function, you have to give
– a vector with the x-axis positions of the labels you want to add. In our case, it will be 1,2,3…until the number of groups you have.
-a vector with the y axis positions. In our case, we have to take the maximum of the value of each plot. These values are given in the $stats attribute of your boxplot.
-a vector with the labels : the number of value per group or whatsoever.
names=c(rep("A", 20) , rep("B", 8) , rep("C", 30), rep("D", 80))
value=c( sample(2:5, 20 , replace=T) , sample(4:9, 8 , replace=T),
sample(1:7, 30 , replace=T), sample(3:8, 80 , replace=T) )
#Draw the boxplot, with the number of individuals per group
a=boxplot(data$value ~ data$names , col=rgb(0.1,0.9,0.3,0.4) , ylim=c(1,10))
text( c(1:nlevels(data$names)) , a$stats[nrow(a$stats) , ]+0.5 , paste("n = ",table(data$names),sep="") )
Not much what you are looking for ?