[R] (no subject)

Mcdonald, Grant grant.mcdonald08 at imperial.ac.uk
Thu Aug 27 13:48:58 CEST 2009


dear sir,

my data larger than this example but is of the following format:

y	x	Age
30	0.0323	O
24	0.0389	Y
158	0.058	Y
120	0.0581	O
100	0.0471	Y
102	0.0615	Y
160	0.0546	O

i ma making a scatter plot of y~x and want to specify different coloured and filled shaped for the points according the the third categorical variable A.

the code i have managed is :

 plot(y~x,pch=as.numeric(factor(Age)))

and i can chage the col seperatley with

 plot(y~xt,pch=as.numeric(factor(maleage)))

and have added a legend with:

legend(locator(1), as.character(levels(factor(maleage))), pch=1:length(levels(factor(maleage))))

However the problem i have is that using this code R selects the shapes or colours for me?  could you help as to how i specify a specific shape for each of the levels in the Age variable?




More information about the R-help mailing list