[R] label separators in boxplots with conditioning

Gabor Grothendieck ggrothendieck at myway.com
Thu Apr 29 13:16:56 CEST 2004


Webb Sprague <wwsprague <at> ucdavis.edu> writes:

: 
: Hi R-helpers,
: 
: I have a data.frame with three columns (lots more reps though in each), 
: like so:
: 
: 'FOO'    'BAR'    'RESULT'
: 1           .01                75
: 1           .05                12
: 1.1        .01                100
: 1.1        .05                50
: 1.2        .01                75
: 1.2        .05                12
: 
: I am calling boxplot(RESULT ~ FOO:BAR, ...)  This gives me the box plots 
: I want, but on the x-axis my labels are "1.01", "1.05", "1.1.01", 
: "1.1.05", "1.2.01", "1.2.01".  I would like to separate the factors by 
: something other than a dot for obvious reasons.  I would also like to 
: *avoid* using the 'names' parameter to boxplot (because I am lazy and 
: want a general solution).

1. Assuming BAR is numeric and always positive and the data frame is z, 
this will insert a minus sign giving you some separation:

   boxplot(RESULT~FOO:I(-BAR),data=z)

2. You could consider replacing BAR with something along the lines of:

   z$BAR <- factor(paste("(",z$BAR,")",sep=""))




More information about the R-help mailing list