Plot regression with interaction in R I did a regression analysis with the following variables: Predictor = dummy variable, dependent Variable = metric, moderator variable = metric. I now want to show my results in a figure. The interaction should be shown by three regression lines. One for moderator = Mean (0), one for moderator = -1 SD, and one for moderator = + 1 SD.
How can I do this in R?
 A: Your suggestion would not display most of the information you have. Instead, display two lines: one for the control group and one for the experimental group. Then you can see all of the information you have, rather than just six points / bars. To see how much more informative the former can be, let's make some pretend data:  
set.seed(4255)                          # this makes the example exactly reproducible

predictor = rep(c("C", "E"), each=50)   # here I'm generating the data & fitting the 
moderator = rnorm(100, mean=20, sd=12)  #  model
dependent = 13 + 5*I(predictor=="E") + 1*moderator + 
            -1*I(predictor=="E")*moderator + rnorm(100, mean=0, sd=4)
model     = lm(dependent~predictor+moderator+predictor:moderator)
summary(model)
# ...
# Coefficients:
#                      Estimate Std. Error t value Pr(>|t|)    
# (Intercept)           13.2640     1.5817   8.386  4.3e-13 ***
# predictorE             2.9518     1.9279   1.531    0.129    
# moderator              0.9869     0.0680  14.513  < 2e-16 ***
# predictorE:moderator  -0.9512     0.0866 -10.983  < 2e-16 ***
# ...

windows()            # this plots the data w/ different symbols & colors
  plot(  moderator[predictor=="C"], dependent[predictor=="C"], 
         col="gray40", xlim=c(-15,50), ylim=c(5,60), xlab="moderator",
         ylab="predictor")
  points(moderator[predictor=="E"], dependent[predictor=="E"], 
         col="cornflowerblue", pch=2)
    # below I calculate the predicted values & plot them as lines over the data
  new.df = data.frame(moderator=-15:50, predictor="C")  
  lines(-15:50, predict(model, new.df))
  new.df = data.frame(moderator=-15:50, predictor="E")
  lines(-15:50, predict(model, new.df), col="darkblue", lty=2)
  legend("topleft", legend=c("C", "E"), col=c("black", "darkblue"), pch=1:2, lty=1:2)


Now let's make a barplot:  
mm     = mean(moderator)  # [1] 19.20544
sdm    = sd(moderator)    # [1] 10.67953
new.df = data.frame(moderator=rep(c(mm-sdm, mm, mm+sdm), times=2), 
                    predictor=rep(c("C","E"), each=3)             )
tab = matrix(predict(model, new.df), ncol=2)
colnames(tab) = c("C","E")

windows()
  barplot(tab, beside=T, col=c("gray25","gray50","gray75"))
  legend("topright", legend=c("-1 SD", "mean", "+1 SD"), pch=15,
         col=c("gray25","gray50","gray75"))


