Skip to content
Prev 299012 / 398506 Next

Code scatter plot data from matrix with 3rd column

Your data is effectively unreadable. Please use dput() to supply sample data.

Here is one way to do what you want  for data frames using the ggplot2 package.

library(ggplot2)
mydata  <-  data.frame(x = 1:10, y = rnorm(10), z = c(rep(1,4), rep(2, 6)))
ggplot(mydata, aes(x, y, colour= as.factor( z))) + geom_point()


John Kane
Kingston ON Canada
____________________________________________________________
GET FREE SMILEYS FOR YOUR IM & EMAIL - Learn more at http://www.inbox.com/smileys
Works with AIM?, MSN? Messenger, Yahoo!? Messenger, ICQ?, Google Talk? and most webmails