It seems that it is not possible to color points that way using stripchart. I found a workaround which solved the problem:
stripchart(values ~ ind, data=mydata.stack, vertical=T, at=c(1.25, 1.75), pch=15, col="white") points(rep(1.25, nrow(mydata)), mydata$val1, col=ifelse(mydata$group == 0, "red", "yellow"), pch=15) points(rep(1.75, nrow(mydata)), mydata$val2, col=ifelse(mydata$group == 0, "red", "yellow"), pch=15) Thanks, - J 2009/12/1 johannes rara <johannesr...@gmail.com>: > I was probably too vague. I meant that the group variable descirbes > the group (eg. different individuals) and val1 and val2 are just two > variables measured from eg. individual. > >> mydata > val1 val2 group > 1 1.1 4.2 0 > 2 3.2 5.3 1 > 3 4.1 3.4 0 > 4 2.5 2.6 1 > 5 6.2 5.3 0 > 6 5.3 6.2 1 > 7 4.5 7.7 0 > 8 2.2 4.8 1 > 9 4.7 3.4 0 > 10 2.7 2.1 1 > > > So, I want to color the points of those groups using different colour. > > - J > > 2009/12/1 David Winsemius <dwinsem...@comcast.net>: >> >> On Dec 1, 2009, at 12:42 AM, johannes rara wrote: >> >>> Hi, >>> >>> Is there a way to get different colour based on group when plotting >>> stripchart? >>> >>> mydata <- data.frame(val1 = c(1.1, 3.2, 4.1, 2.5, 6.2, 5.3, 4.5, 2.2, >>> 4.7, 2.7), val2 = c(4.2, 5.3, 3.4, 2.6, 5.3, 6.2, 7.7, 4.8, 3.4, 2.1), >>> group = rep(0:1, 5)) >>> mydata.stack <- stack(mydata, select=-group) >>> >>> stripchart(values ~ ind, >>> data=mydata.stack, >>> vertical=T, >>> at=c(1.25, 1.75), >>> pch=15, >>> col="red") >>> >>> I would like to get different colour for the two groups (based on >>> group variable). I tried something like >>> >>> stripchart(values ~ ind, >>> data=mydata.stack, >>> vertical=T, >>> at=c(1.25, 1.75), >>> pch=15, >>> col=c("red", "yeallow")[mydata$group]) >> >> Doesn't this work? >> >> stripchart(values ~ ind, >> data=mydata.stack, >> vertical=T, >> at=c(1.25, 1.75), >> pch=15, >> col=c("red", "yellow") ) >> >> I would not think that mydata$group would be "in sync" with the dataset that >> you are passing to stripchart. >> >> -- >> David >> >> David Winsemius, MD >> Heritage Laboratories >> West Hartford, CT >> >> > ______________________________________________ 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.