gni456 发表于 2015-1-29 09:48 
先把数据按X从小到大排序再用lines()就好了
X
> X <- c(10.0, 8.0, 13.0, 9.0, 11.0, 14.0, 6.0, 4.0, 12.0, 7.0, 5.0)
> Y <- c(9.14,8.14, 8.74,8.77,9.26,8.10,6.13,3.10, 9.13,7.26,4.74)
> a <- data.frame(X,Y)
> a <- a[order(X), ]
> fit <- lm(Y~X+I(X^2),data=b)
Error in as.data.frame.default(data, optional = TRUE) :
cannot coerce class ""function"" to a data.frame
> plot(X,Y)
> lines(a$X,fitted(fit))
Error in fitted(fit) : 找不到对象'fit'
请问这是为什么啊?