Add Sample Sizes Above Plot in BaseR

Hello

You might want to post a reproducible example with a dataset.
FAQ: How to do a minimal reproducible example ( reprex ) for beginners - General - Posit Community

However, I think something along these lines works

n=100
a <- data.frame(site=sample(c('A','B','C'),n,replace=TRUE),
                value=rnorm(n,50,50))

data <- tapply(a$value,a$site,mean)
n <- tapply(a$value,a$site,length)

p <- barplot(data,ylim=c(0,100))
text(x=p,y=data+5,paste('n =',n))

Best wishes

Michael

2 Likes