[R] Colors vector based on group

Filoche pmassicotte at hotmail.com
Mon Feb 6 15:40:27 CET 2012


Hi everyone.

I have a vector like this:

x =
c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,2)

I would like to associate a colour to each of these entry. For example, I
could use /topo.colors(3)/ (since I have 3 groups).

I know it is easy to do this with  /if/else/ statements, but I would like to
find a proper way to do this.

Thanks in advance,
Phil



--
View this message in context: http://r.789695.n4.nabble.com/Colors-vector-based-on-group-tp4361425p4361425.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list