可有人請告訴我如何與ggplot(通過使用this工具生成的代碼)下面的互動效應繪製:如何將回歸交互圖轉換爲ggplot?
xx <- c(40,65)
yy <- c(26.77,37.15)
x <- c(40,65) # <-- x-coords for lines
y1 <- c(28.5,37.15)
y2 <- c(30.345,35.895)
y3 <- c(32.19,34.64)
plot(xx,yy,type='n',font=2,font.lab=2,xlab='x1',ylab='Y',main='2-Way Interaction Plot')
lines(x,y1,lwd=3,lty=1,col=1)
lines(x,y2,lwd=3,lty=5,col=2)
lines(x,y3,lwd=3,lty=6,col=3)
points(x,y1,col=1,pch=16)
points(x,y2,col=1,pch=16)
points(x,y3,col=1,pch=16)
legend(leg[1],leg[2],legend=c('W1(1)','W1(2)','W1(3)'),lwd=c(3,3,3),lty=c(1,5,6),col=c(1,2,3))
Y1,Y2,Y3是主持人點/有條件的斜率值。
歡迎來到交叉驗證!但是這個問題是關於編程的,在堆棧溢出時會更好。 – Scortchi
我希望[this](http://www.cookbook-r.com/Graphs/Bar_and_line_graphs_%28ggplot2%29/#with-x-axis-treated-as-continuous)和[this](http:// docs .ggplot2.org/current/stat_summary.html)例子會讓你開始。 – Henrik
請檢查你的語法。 「leg [1]」和「leg [2]」是什麼? – Frank