Skip to content
Prev 262523 / 398502 Next

Side by side scatter plots with specified regression lines

Dear Sigrid,
At 12:46 PM -0700 6/12/11, Sigrid wrote:
Here is an example that might help:
library(psych)  #in order to get the sat.act data set
  my.data <- sat.act
  with(my.data,plot(SATV~SATQ,   col=c("blue","red")[gender]))
  by(my.data,my.data$education,   function(x) abline   (lm(SATV~SATQ,data=x),
     lty=c("solid", "dashed", "dotted",  "dotdash", "longdash", 
"twodash")[(x$education+1)]))

#to make two scatter plots side by side, use
op <- par(mfrow=c(1,2))


I hope this helps.

Bill