[R] sample size in box plot labels

PIKAL Petr petr.pikal at precheza.cz
Fri Apr 26 13:00:15 CEST 2013


Hi

> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Shane Carey
> Sent: Friday, April 26, 2013 11:49 AM
> To: r-help at r-project.org
> Subject: [R] sample size in box plot labels
> 
> 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))

Does not work without data.

Do you want something like this?

boxplot(Sepal.Length~Species, data=iris)
mtext(as.character(table(iris$Species)), 1, at=1:3)

Regards
Petr



> 
> 
> --
> Shane
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list