[R] Color of the plot which correspond to the group of the observations

FMH kagba2006 at yahoo.com
Thu Sep 24 20:28:44 CEST 2009


Dear All,
 
Let:

dp: depth of the river
tp: temperature with respect to depth

These pair of observations are in 3 different groups i.e:
Obs. 1,3,5,7 from the first group
Obs. 2,4 and 10 from second group
Obs 6,8 and 9 from third group.

We can have a simple scatter plot, between depth as y-axis and temperature as x-axis, with each pairs are denoted by a red dot, by using a plot function shown below.
 
#####################
 dp <- c(1,4,3,2,5,7,9,8,9,2)
 tp <- 1:10
 plot(tp,dp, type= 'p', col = 'red')
 #####################

Could someone please give some advices on the way  to have a plot in which the color of each pair of observation corrrespond to its group? For instance, we might have red, blue and green dots corresponding to groups 1,2 and 3, respectively. 


Thank you
Fir







More information about the R-help mailing list