Skip to content
Prev 12552 / 398502 Next

pch with plot and legend

I'm trying to plot a scatterplot of two variables using pch to plot
different characters based on a third factor. Here is my example
[1] "OJ" "VC"
The command as.numeric(supp) returns 2 2 2 2 ...  1 1 1 ... for the
factor supp which the plot command uses nicely, but the pch command
for the legend uses the first two values 2 2 for the command. This
isn't correct of course. How can I get the correct numbers for the pch 
command for the levels? I tried pch=as.numeric(levels(supp)) in legend 
but that didn't work. 

Thanks for any help.

John