[R] colour coding and different point types in a plot

Martin Maechler maechler at stat.math.ethz.ch
Tue Jan 8 16:07:52 CET 2002


>>>>> "MGrum" == Grum, Mikkel <M.GRUM at CGIAR.ORG> writes:

    MGrum> I'm trying to plot four different sorghum types on a
    MGrum> plot using a different colour/symbol combination for
    MGrum> each sorghum type (TYPBOTA in the script below).
    MGrum> What am I doing wrong?:

-- you mean, apart from using hard/horrible to read all-uppercase
    variable names  :-))  aka `big grin' -


    MGrum> plot(xx$LATITUDE,xx$SFD1,

I assume this command goes on and is finished in your real example ..

    MGrum> points(xx$SFD1,xx$LATITUDE,
    MGrum>        col=1:4[codes(xx$TYPBOTA)],pch=c(4,3,1,2)[codes(xx$TYPBOTA)])

    MGrum> I get the following error message
    MGrum> Error in 1:4[codes(xx$TYPBOTA)] : NA/NaN argument
    MGrum> In addition: Warning message: 
    MGrum> Numerical expression has 162 elements: only the first used in:
    MGrum> 1:4[codes(xx78$TYPBOTA)] 

Maybe look at this ?

 > 1:4[c(3,1,2,NA,4,2)]
 Error in 1:4[c(3, 1, 2, NA, 4, 2)] : NA/NaN argument
 In addition: Warning message: 
 Numerical expression has 6 elements: only the first used in: 1:4[c(3, 1, 2, NA, 4, 2)] 

 > (1:4)[c(3,1,2,NA,4,2)]
 [1]  3  1  2 NA  4  2


Morale of the story: always use "(..)" when in doubt

Regards,

Martin Maechler <maechler at stat.math.ethz.ch>	http://stat.ethz.ch/~maechler/
Seminar fuer Statistik, ETH-Zentrum  LEO C16	Leonhardstr. 27
ETH (Federal Inst. Technology)	8092 Zurich	SWITZERLAND
phone: x-41-1-632-3408		fax: ...-1228			<><
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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