Adding Multiple Sample Size Values to a Box plot

#1
Hello,

I am working on a boxplot where I would like the N (sample size) to be displayed on each box and also the different number of trials that the samples came from..

I have some sample data as follows:

Code:
structure(list(Female.Name = structure(c(3L, 3L, 3L, 5L, 5L, 
5L, 5L, 4L, 4L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L), .Label = c("five", 
"four", "one", "three", "two"), class = "factor"), Day = c(1, 
2, 3, 1, 2, 3, 4, 1, 4, 1, 2, 3, 3, 3, 1, 4, 4), Time = c(0.3, 
0.4, 0.5, 0.2, 0.4, 0.5, 0.6, 0.2, 0.6, 0.2, 0.3, 0.4, 0.6, 0.4, 
0.3, 0.6, 0.6)), .Names = c("Female.Name", "Day", "Time"), row.names = c(NA, 
-17L), class = "data.frame")
And my code looks like this:

Code:
data<-read.csv('Example Data.csv')
data$Time<-as.character(data$Time)
data$Time<-as.numeric(data$Time)
data$Day<-as.character(data$Day)
data$Day<-as.numeric(data$Day)

#boxplot of Days in Paradigm vs Time on 'Choice Side'

boxplot(data$Time~data$Day, col='purple', xlab='Days After Entry', ylab='Proportion of time on Choice Side', main='Time ')
So how do I add the N.. and also, if my data is clear enough, how do I add the number of different trials or 'Female.Name', as it is labeled in my sample data...?


Thank you
 

bugman

Super Moderator
#2
Here is one solution...


Code:
val<-c(1,2,3,4....)
mtext(side = 3,  text =val , at=c(1:ncol(data)),line = -2,col="red",cex=0.8)