Skip to content

(no subject)

2 messages · Mcdonald, Grant, jim holtman

#
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?
#
Setup a vector with the shapes and the colors you want that are the
same length as the number of levels in Age:
y      x Age
1  30 0.0323   O
2  24 0.0389   Y
3 158 0.0580   Y
4 120 0.0581   O
5 100 0.0471   Y
6 102 0.0615   Y
7 160 0.0546   O
On Thu, Aug 27, 2009 at 7:48 AM, Mcdonald,
Grant<grant.mcdonald08 at imperial.ac.uk> wrote: