[R] Adding mean line to a lattice density plot
K. Elo
maillists at nic.fi
Thu Mar 8 08:35:31 CET 2012
Hi!
I have used the following command:
densityplot(~PV1CIV, groups=SGENDER, data=ISGFINC2,
lwd=2, col=1, lty=c(1,2), pch=c("+","o"),
key=list(text=list(lab=levels(ISGFINC2$SGENDER), col=1),
space="bottom", columns=2, border=T, lines=T, lwd=2,
lty=c(1,2), col=1), ref=T, plot.points=F)
to produce a lattice density plot presenting the distribution of
achievment points grouped by the gender of the respondents.
Now, in order to clarify the difference between boys and girls, I would
like to add two vertical lines: one for the mean of boys, the other for
the mean of girls. How could I do this (I have tried to use the function
'panel.abline', but could not figure out how to define the correct
x-axis point (using 'v=mean(PV1CIV[ SGENDER==1 ])' as a parameter is not
working...).
Thanks in advance,
Kimmo
More information about the R-help
mailing list