0
我绘制了15个包含回归线的散点图。不过,我想在一个页面上展示以更好地形象化。 grid.arrange函数有助于根据我们的兴趣添加多个图,但是我总是面对一个错误。在一个页面上添加多个图格.arrange函数
错误为Glist(列表(wrapvp =列表(x = 0.5,Y = 0.5,宽度= 1,高度= 1,: 仅在 “为Glist” 允许
plots <- list()
for (i in 1:(ncol(xx2)-1)) {
cn <- colnames(xx2)
reg<-lm(xx2[,i]~xx2[,16], data=data.frame(xx2))
aa<-summary(reg)
p1<-plot(xx2[,16], xx2[,i], xlab=cn[16], ylab=cn[i],
pch=1, cex.main=1.5, frame.plot=FALSE, col="grey")+ abline(reg, col="blue", lwd=2) + text(max(xx2[,16]/1.3), max(xx2[,i])/2, paste("R-Squared:",round(aa$r.squared,3)),cex = .8)
#plot(density(resid(reg)))
plots[[i]] <- p1
}
grid.arrange(grobs = plots[1:15], ncol=5)
'grobs' OR
do.call(grid.arrange, c(plots, ncol=3))
我在编辑删除错误的标签。 –