[R] pairs and panel.smooth for two groups
Marie-Pierre Sylvestre
mp.sylvestre at gmail.com
Wed Sep 8 16:03:11 CEST 2010
Hi,
I have modified the USJudgeRatings data (available in R) to
illustrate my question.
# Use the first 4 variables of USJudgeRatings and add a group variable
with two levels
USJudgeRatings <- USJudgeRatings[,1:4]
USJudgeRatings$group <- factor(c(rep(1, 22), rep(0, 21)))
# I can draw a pairs graph where members of each group are drawn in
different colors:
pairs(USJudgeRatings[,1:4], col = c(2,3)[USJudgeRatings$group], pch =
c(21,3)[USJudgeRatings$group])
# I would also like to add a smooth line to each subplot like
pairs(USJudgeRatings[,1:4], panel=panel.smooth)
# but I want the smooth to be done for each of the group, i.e. I want
two smooths per subplot.
# this creates only one smooth
pairs(USJudgeRatings[,1:4], col = c(2,3)[USJudgeRatings$group], pch =
c(21,3)[USJudgeRatings$group], panel = panel.smooth)
# I understand that panel.smooth is a function that is called for each
subplot. I don't know how to tell it to do a smooth for each of my
group in each of the subplot.
Any help would be appreciated!
Best,
Marie-Pierre
More information about the R-help
mailing list