[R] Coloring Stripchart Points, or Better, Lattice Equivalent

From: Bryan Hanson <hanson_at_depauw.edu>
Date: Sat, 21 Jun 2008 13:40:45 -0400


Hi All.

I have the commands below to create a stripchart/plot. I was hoping to color the points in the plot by yr, and use a symbol that varied with resp. However, the outcome makes it appear as though the point by point col and pch data is not being passed properly. Any suggestions?

And truthfully, Iıd rather be doing this with Lattice, but Iıve tried several variations of stripplot and canıt even get something with the general layout of the stripchart version.

Thanks, Bryan



Bryan Hanson
Professor of Chemistry & Biochemistry
DePauw University, Greencastle IN USA

index <- round(runif(100, 1, 100))
resp <- rbinom(100, 1, 0.5)
yr <- rep(c("2005", "2006"), 50)
all <- data.frame(index, resp, yr)
for (n in 1:length(all$index)) {

    if (all$yr[n] == 2005) {all$col[n] <- "red"}     else {all$col[n] <- "blue"}
}

for (n in 1:length(all$index)) {

    if (all$resp[n] == 1) {all$sym[n] <- 1}     else {all$sym[n] <- 3}
}

stripchart(all$index, method = "stack", ylim = c(0,10), col = all$col, pch = all$sym)



R-help_at_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. Received on Sat 21 Jun 2008 - 17:43:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 22 Jun 2008 - 16:30:43 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive