[R] Scatterplot - symbols coded by factor
Matt Pocernich
mjpocern at ouray.cudenver.edu
Sat Feb 10 05:05:10 CET 2001
Hi - I would like to create a scatterplot with the symbols coded by a factor in each record. Is their a better way than what I have used below? I attempted to use the plot.factor, but cannot force it to make a scatterplot instead of boxplots. I have considerd making a function with a 'for' statement for each level of the factor. Is there a better way for when I am dealing with more levels of factors?
Thanks, Matt Pocernich
Y <- c(40,38,30,47,25,32,13,35,27,24,20,13)
X<-c(110,75,93,97,60,75,38,140,62,90,45,59)
manuf <- factor(rep(LETTERS[1:3],c(4,4,4)))
data3 <- data.frame(X,Y,manuf)
attach(data3)
plot(X, Y, type="n")
points(X[manuf=="A"], Y[manuf=="A"], pch = "A")
points(X[manuf=="B"], Y[manuf=="B"], pch = "B")
points(X[manuf=="C"], Y[manuf=="B"], pch = "C")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://stat.ethz.ch/pipermail/r-help/attachments/20010209/5db1c70d/attachment.html
More information about the R-help
mailing list