On the subject of boxplots, I have multiple data sets of unequal sample sizes and was wondering what would be the most efficient way to read in the data and plot side-by-side boxplots, with options for controlling the orientation of the plots (i.e. vertical or horizontal) and the spacing? Your assistance is greatly appreciated, but please try to be explicit as I am no R expert.

Thanks Janh

Not sure without a reproducible example (please read posting guide) but maybe this will help:

a = sample(1:100, 30)
b = sample(1:100, 50)
c = sample(50:100,19)
d = sample(1:50, 15)
e = sample(1:50, 15)
f = sample(1:50, 25)

x11(width = 7, height = 3.5)
op =par(mfrow = c(1,2))  # plot side by side

# horizontal
boxplot(list(a,b,c), horizontal = TRUE, main = 'Horizontal',
    xlim = c(0,9), names = c('a', 'b','c'))
boxplot(list(e, f), horizontal = TRUE, xlim = c(0,9), names = c('e', 'f'),
    at = c(7,8), add = TRUE, col ='red')

# vertical
boxplot(list(a,b,c), horizontal = FALSE, xlim = c(0,9), main = 'Verticalal',
     names = c('a', 'b','c'))
boxplot(list(e, f), horizontal = FALSE, xlim = c(0,9), names = c('e', 'f'),
    at = c(7,8), add = TRUE, col ='red')
par(op)

Cheers,

Rob



___
 Robert W. Baer, Ph.D.
Professor of Physiology
Kirksille College of Osteopathic Medicine
A. T. Still University of Health Sciences
Kirksville, MO 63501 USA

______________________________________________
R-help@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.

Reply via email to