当我尝试将abline()
拟合线甚至基本线添加到现有情节时,lm()
会出现奇怪的行为。
x = seq(1:5)
y = seq(2,10,2)
plot(y~x)
abline(lm(y~x))
得到我:
Error in xy.coords(x, y) : argument "y" is missing, with no default
类似地:
abline(h = 2)
给予
Error in points(x, y, pch = pch, col = col, bg = bg, cex = cex) :
argument "x" is missing, with no default
如果我提取abline
代码,我会看到:
function (x, y, col = par("col"), bg = NA, pch = par("pch"), cex = 1, col.smooth = "red", span = 2/3, iter = 3, ...)
{
points(x, y, pch = pch, col = col, bg = bg, cex = cex)
ok <- is.finite(x) & is.finite(y)
if (any(ok))
lines(stats::lowess(x[ok], y[ok], f = span, iter = iter),
col = col.smooth, ...)
}
helpfile的函数语法为abline(a = NULL, b = NULL, h = NULL, v = NULL, reg = NULL, coef = NULL, untf = FALSE, ...)
我是否有可能通过安装另一个覆盖了abline()
功能的软件包来破坏R图形软件包的某些部分?如果是这样,我该如何检查和修复?
干杯,
戴夫