[R] Creating two lines of best fit on a scatter plot

Samantha Reynolds sam.m.reynolds at hotmail.com
Wed Apr 7 19:30:08 CEST 2010


I am trying to plot two lines of best fit on a scatter plot.

I'm plotting number of visits (y) against personality (x), half the  
plots are blue for patchchoice  one and the other plots are red for  
patchchoice two (these options come from one factor, see below) . So i  
need a line for the patch ones and another line for the patch twos.  
How would i go about doing this? I know i may need to use the subset  
command, but I'm not entirely sure how to do this as I am relatively  
new to R

example of data
birdid timetaken numvisits ptachchoice time bold
1087         8        10           1   AM    0
1087        28         6           1   PM    0
1087        13         3           2   AM    0
1087       121         0           2   PM    0
1046       121         0           1   AM    1
1046       121         0           1   PM    1



More information about the R-help mailing list