[R] Histograms per coding variable - labelling the plots
Ben Bolker
ben at zoo.ufl.edu
Thu Dec 6 18:01:07 CET 2001
The best I can do is a bit of a hack, really a for loop in disguise:
f <- factor(rep(LETTERS[1:10],rep(10,10)))
tmp <- split(a,f)
par(mfrow=c(3,4))
sapply(1:length(tmp),function(i)hist(tmp[[i]],main=names(tmp)[i]))
If anyone has a better idea ...
I've often wished for a "MapThread" (cf. Mathematica) or "zip" function
or something similar that would apply a two- (or more-) parameter function
to parallel lists/vectors. One could write one's own in R code, but I
don't know that there would be any real advantage beyond elegance.
On Thu, 6 Dec 2001, Smit, A, Albertus, Dr wrote:
> Dear all
>
> Thank you to all who replied to the question regarding plotting
> histograms for a series of coding variables. The tapply() function
> seems to work well, and so does the lattice package.
>
> Kaspar Pflugshaupt also pointed out the following:
>
> > With some tricks, you can even have a title with the respective label over
> > each plot... but I forgot how I did this.
>
> Does anyone know how to do this?
>
> Thank you again,
> Albertus
> Dr Albertus J. Smit
> Department of Botany
> University of Cape Town
> PO Box Rondebosch
> 7700
> SOUTH AFRICA
> Tel. 689 3032
> Fax. 650 4041
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
--
318 Carr Hall bolker at zoo.ufl.edu
Zoology Department, University of Florida http://www.zoo.ufl.edu/bolker
Box 118525 (ph) 352-392-5697
Gainesville, FL 32611-8525 (fax) 352-392-3704
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list