[R] pch with plot and legend

About this list Date view Thread view Subject view Author view Attachment view

From: John Verzani (verzani@math.csi.cuny.edu)
Date: Thu 26 Jul 2001 - 02:45:27 EST


Message-id: <15198.63399.995707.279452@wiener.math.csi.cuny.edu>

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

> data("ToothGrowth")
> attach(ToothGrowth)
> levels(supp)
[1] "OJ" "VC"
> plot(len ~ dose,pch=as.numeric(supp))
> legend(locator(1),pch=as.numeric(supp),legend=levels(supp))

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

-- 
....................................................................
.  John Verzani                  mailto:verzani@math.csi.cuny.edu  .
.  Dept. of Mathematics      http://www.math.csi.cuny.edu/~verzani .
.  City University of New York                 tel: (718) 982-3623 .
.  College of Staten Island                    fax: (718) 982-3631 .
.  Staten Island, NY 10314                                         .
....................................................................
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Wed 10 Mar 2004 - 08:18:21 EST