我正在循环中对许多数据集进行线性拟合,并将结果绘制在 pdf 文件中。是否可以直接将summary(fit)的输出保存在同一个pdf文件中,而不是通过控制台观察大约100个数据集的摘要?
LMmodel <- y ~ x
fit <- lm(LMmodel, data = Dataset)
pdf(file = OutputFile, width = 10, height = 6, paper = "a4r")
xLim = range(x)
yLim = range(y)
plot(x, y, type = "p", xlim = xLim, ylim = yLim,
main = plotTitle, xlab = "x [m]", ylab = "y [dB]",
pch = 20, cex = .9)
regLine(fit, col=palette()[2], lwd=2, lty=1)
grid(lwd = 1.5)
plot(density(residuals(fit)), main = "Density Plot of the Residuals"))
dev.off()
graphics.off()
return(summary(fit))