[R] a loop for boxplot graphs

Coen van Hasselt coenvanhasselt at gmail.com
Sun Mar 29 23:50:26 CEST 2009

You could use the paste() function to dynamically assign label values.
For instance, like this:

for (i in dat$id){
	  main=paste("Results for Subject",i) )

There might be a better answer though- e.g. avoiding a for-loop.


On Mon, Mar 30, 2009 at 07:08, James Lenihan <jameslenihan at sbcglobal.net> wrote:
> Dear Colleagues
> I have the following code that generates a boxplot for one specific labtest:
> boxplot.n(LBSTRESN~COHORT, main="Boxplot of laboratory data for XLXXX-XXX test=Creatinine",
> subset = LBTEST=="Creatinine",
> xlab = "Cohort Number",
> ylab = "Units = umol/L",
> varwidth=TRUE
> I would like to know if there is a way to loop through the dataset and produce the boxplot for a number of specific labtest.
> Looking at the documentation for loops I can't see how I would change the "ylab","main"and "subset"
> Can someone refer me to a similar example in the online documentation?
> Thanks,
> Jim L
>        [[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