I am making a scatter plot of two variables and would like to colour the points by a factor variable. Here is some reproducible code:
data <- iris plot(da
The lattice library is another good option. Here I've added a legend on the right side and jittered the points because some of them overlapped.
lattice
xyplot(Sepal.Width ~ Sepal.Length, group=Species, data=iris, auto.key=list(space="right"), jitter.x=TRUE, jitter.y=TRUE)