[R] colour coding and different point types in a plot
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Jan 8 16:03:05 CET 2002
"Grum, Mikkel" <M.GRUM at CGIAR.ORG> writes:
> I'm trying to plot four different sorghum types on a plot using a different
> colour/symbol combination for each sorghum type (TYPBOTA in the script
> below). What am I doing wrong?:
>
> plot(xx$LATITUDE,xx$SFD1,
> points(xx$SFD1,xx$LATITUDE,
> col=1:4[codes(xx$TYPBOTA)],pch=c(4,3,1,2)[codes(xx$TYPBOTA)])
> grid()
>
> I get the following error message
> Error in 1:4[codes(xx$TYPBOTA)] : NA/NaN argument
> In addition: Warning message:
> Numerical expression has 162 elements: only the first used in:
> 1:4[codes(xx78$TYPBOTA)]
I think you need (1:4)[...] (and maybe also reconsider the use of
codes(). It has certain surprises, and indexing with a factor is the
same as using foo[as.integer(f)])
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list