服务热线
178 0020 3020
X <- c(0.11,0.12,0.13,0.14,0.15,0.16,0.17,0.18,0.19,0.20,0.23) Y <- c(42.0,43.5,45.0,45.5,45.0,47.5,49.0,53.0,50.0,55.0,55.0) plot(X,Y) a=lm(Y~X) b=summary(a) abline(a) #print(b$coefficients[2,1]) text=paste("Y=",round(b$coefficients[1,1],2),"+",round(b$coefficients[2,1],2),"*X") print(text); mtext(text)
data<- read.csv(file.choose()) y <-data$CON x <-data$std_ave a <-lm(y~x) plot(x,y) abline(a,col = 'green',lwd = 1,lty = 1) sam <- data.frame(x = data$sam_ave) sam_pred <- predict(a,sam,interval = "prediction",level = 0.95) points(data$sam_ave,sam_pred[,1],col = "red",pch = c("A","B","C","D"),cex =3)
在上述代码下再加上如下代码:
par(mfrow=c(2,2)) plot(a)
附件