nrep = 1000 ## The second instrument has twice the variance, but we get to ## use twice the sample size. nx = 10 vx = 1 ny = 20 vy = 2 ## Generate the data for the first instrument. D = rnorm(nrep*nx, sd=sqrt(vx)) X = array(D, c(nrep,nx)) MX = apply(X, 1, mean) ## Generate the data for the first instrument. D = rnorm(nrep*ny, sd=sqrt(vy)) Y = array(D, c(nrep,ny)) MY = apply(Y, 1, mean) ## Concatenate the means into a single vector. M = c(MX, MY) ## A group id vector. G = c(array(1, 1000), array(2, 1000)) ## Generate side by side boxplots. boxplot(M ~ G, names=c('First instrument', 'Second instrument'))