[R] Histograms per coding variable - labelling the plots
    Michael A. Miller 
    mmiller3 at iupui.edu
       
    Thu Dec  6 20:23:27 CET 2001
    
    
  
>>>>> "Smit," == Smit, A, Albertus, Dr <ajsmit at botzoo.uct.ac.za> writes:
    >>>>> 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?
If your data looks, for example, like this
score activity
low   22.2
low   97.8
low   29.1
...
med   19.0
med   19.8
med   9.1
med   30.1
med   15.5
med   10.3
med   11.0
...
high  10.2
high  11.3
high  11.4
high  5.3
high  14.5
you could do something like this:
par( mfrow=c(2,2) )
for ( level in levels(score) ) {
  hist( activity, main=paste('score : ', level ))
}
If you use lattice, you can produce slightly different labels by
using strip.default, as in:
library(lattice)
histogram( ~ activity | score, data=nk, 
  strip = function(...) strip.default(style=2,...) 
)
or
histogram( ~ activity | score, data=nk, 
  strip = function(...) strip.default(style=1,strip.names=T,...) 
)
Mike
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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