[R] sample size in box plot labels

Rui Barradas ruipbarradas at sapo.pt
Fri Apr 26 13:02:11 CEST 2013


Hello,

To count the sample sizes for each factor try

tapply(DATA$K_Merge, DATA$UnitName_1, FUN = length)


Hope this helps,

Rui Barradas

Em 26-04-2013 10:48, Shane Carey escreveu:
> Hi,
>
> I would like to put the sample number beside each lable in a boxplot.
> How do I do this? Essentially, I need to count the sample size for each
> factor, see below:
> Thanks
>
> boxplot(DATA$K_Merge~factor(DATA$UnitName_1),axes=FALSE,col=colours)
> title(main=list("Tukey Boxplot by Geology:\n K(%)",cex=cexlb))
> axis(1, 1:21, labels=FALSE, las=2)
> text(seq(1, 21, by=1), par("usr")[3], labels =
> levels(factor(DATA$UnitName_1)), srt = 45,  adj = c(1.03,1.03), xpd = TRUE,
> cex=1.8)
> axis(2, seq(-1,5, 1), seq(-1, 5, 1))
>
>



More information about the R-help mailing list