使用图形

attach(mtcars)
plot(wt, mpg)
abline(lm(mpg~wt))
title(“Regression of MPG on Weight”)
detach(mtcars)
首句绑定了数据框 mtcars 。第二条语句打开了一个图形窗口并生成了一幅散点图,横轴表示车身重量,纵轴为每加仑汽油行驶的英里数。第三句向图形添加了一条最优拟合曲线。第四句添加了标题。最后一句为数据框解除了绑定。

你可能感兴趣的:(使用图形)