Skip to content
Prev 314758 / 398506 Next

plot xaxp issue

Hi
It is not about drawing plot many times but coding points or graphic objects by some factor. In your case sex.
Instead of
boyline<-lm(body_weight ~ body_length, boy)

use collective data frame together and subset only one sex.

boyline<-lm(body_weight ~ body_length, data=together, subset(sex=="boy"))
abline(boyline,col="firebrick3",lwd=2)

In case of more than two sexes (some SF authors mentioned it is possible) you can use simple loop.

for (i in 1:2)) {
subs <- together$sex==levels(together$sex)[i]
line<-lm(body_weight ~ body_length, data=together, subset=subs)
abline(line, col=c("firebrick3","saddlebrown")[i],lwd=2) 
}
They will. You can try it yourself. Sometimes R functions are quite close to magic. 

Regards
Petr