Thank you, David.
What I actually would like to do in an more elegant way is the following
boxplot (meinspss$attr_diff_gesamt ~ meinspss$R1_02)
boxplot (meinspss$finanz_diff_gesamt ~ meinspss$R2_02)
boxplot (meinspss$leist_diff_gesamt ~ meinspss$R3_02)
boxplot (meinspss$soz_diff_gesamt ~ meinspss$R4_02)
boxplot (meinspss$wert_diff_gesamt ~ meinspss$R5_02)
As the final code is much more complicated (see below) I was looking for a
loop oder lapply() way to do it
Thanks gain for you help.
Andrew
+
with (meinspss, {
beanplot(dimension ~ gruppe, ll=0.04, what=c(1,1,1,1), jitter = 1.2,
main = titel, ylab=Differenzwert, names = c(Aufwärts, Lateral,
Abwärts ),
overalline = mean, beanlines = median, col=c(orange,yellow,bisque,
white))
## Run boxplot to find statistics, but don't draw the boxplots
S - boxplot(dimension ~ gruppe, names = c(Aufwärts, Lateral,
Abwärts), plot=FALSE)
## Define locations for additional chart elements
at - c(1:length(S$names))
means - by(dimension, gruppe, mean, na.rm=TRUE)
points(at,means, pch = 23, cex = 1.2, bg = blue)
## Draw Mean values to the left edge of each violinplot
text(at - 0.3, means, labels = formatC(means, format = f, digits = 1),
pos = 2, cex = 1, col = blue)
## Draw Median values to the right edge of each violinplot
text(at + 0.3, S$stats[3, ], labels = formatC(S$stats[3, ],
format = f, digits = 1), pos = 4, cex = 1, col = darkgreen)
##- Get CIs -##
## create standard error function--
se - function(x) {
y - x[!is.na(x)]
sqrt(var(as.vector(y))/length(y))
}
## create length function for non-missing values
lngth - function(x){
y - x[!is.na(x)]
length(y)
}
## Compute vectors of standard error and n
Hse - by(dimension, gruppe,se)
Hn - by(dimension, gruppe,lngth)
## compute 95% CIs and store in vectors
civ.u - means + qt(.975, df=Hn-1) * Hse # Upper bound CI
civ.l - means + qt(.025, df=Hn-1) * Hse # Lower bound CI
## Draw CI, first vertical line, then upper and lower horizontal
segments(at, civ.u, at, civ.l, lty = solid, lwd = 2, col = red)
segments(at - 0.1, civ.u, at + 0.1, civ.u, lty = solid, lwd =2,col =
red)
segments(at - 0.1, civ.l, at + 0.1, civ.l, lty = solid, lwd =2,col =
red)
## Print n under the name of measure
mtext(S$n, side = 1, at = at, cex=.75, line = 2.5)
mtext(S$names, side = 1, at = at, cex=1, line = 1)
})
--
View this message in context:
http://r.789695.n4.nabble.com/How-to-produce-serveral-plots-with-pairs-of-vectors-tp4540968p4541164.html
Sent from the R help mailing list archive at Nabble.com.
__
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.