如何在R in图中动态指示组
这是我的数据如何在R in图中动态指示组,r,R,这是我的数据 x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22) y = c(1, 6, 2, 5, 4, 7, 9, 6, 8, 4, 5, 6, 5, 5, 6, 7, 5, 8, 9, 5, 4, 7) plot(x, y) fit <- lm(y ~ x) fit abline(fit, col = "black", lwd = "1") x=c(1
x = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22)
y = c(1, 6, 2, 5, 4, 7, 9, 6, 8, 4, 5, 6, 5, 5, 6, 7, 5, 8, 9,
5, 4, 7)
plot(x, y)
fit <- lm(y ~ x)
fit
abline(fit, col = "black", lwd = "1")
x=c(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
17, 18, 19, 20, 21, 22)
y=c(1,6,2,5,4,7,9,6,8,4,5,6,5,5,6,7,5,8,9,
5, 4, 7)
绘图(x,y)
拟合您可以使用predict
获得每个x处的拟合值,然后对观测值和拟合值进行逻辑比较,以测试它们是否在直线上方或下方。然后根据此逻辑比较设置打印的颜色
prediction <- predict(fit)
colors<-ifelse(y>prediction,1,2)
plot(x,y,col=colors)
abline(fit, col= "black",lwd="1")
predict您可以使用predict
获得每个x处的拟合值,然后对观测值和拟合值进行逻辑比较,以测试它们是否在直线上方或下方。然后根据此逻辑比较设置打印的颜色
prediction <- predict(fit)
colors<-ifelse(y>prediction,1,2)
plot(x,y,col=colors)
abline(fit, col= "black",lwd="1")
prediction谢谢,我怎样才能保存这两个组?在不同的数据中以上预测]
和以下谢谢,我如何保存这两个组?在不同的数据中以上预测]
和以下