R图中的边界
对于下面给出的示例,如何绘制虚线之间的区域 代码如下:R图中的边界,r,plot,border,R,Plot,Border,对于下面给出的示例,如何绘制虚线之间的区域 代码如下: X <- rnorm(100) Y<- X + rnorm(100) reg<-lm(Y~X) CI <- predict(reg,interval="confidence") F <- CI[,1] L <- CI[,2] U <- CI[,3] plot(X,F) abline(reg, col="red") reg2<-lm(L~X) abline(reg2, co
X <- rnorm(100)
Y<- X + rnorm(100)
reg<-lm(Y~X)
CI <- predict(reg,interval="confidence")
F <- CI[,1]
L <- CI[,2]
U <- CI[,3]
plot(X,F)
abline(reg, col="red")
reg2<-lm(L~X)
abline(reg2, col="red", lty="dashed")
reg3<-lm(U~X)
abline(reg3, col="red", lty="dashed")
X似乎它应该是一个副本,但我在SO搜索中找不到它。我知道它在rhelp上出现过很多次。但这是一笔财富:
require(fortunes)
fortune("every question")
Lastly, by what we could call the 'Liaw-Baron principle', every question that can be
asked has in fact already been asked.
-- Dirk Eddelbuettel (citing Andy Liaw's and Jonathan Baron's opinion on unique
questions on R-help)
R-help (January 2006)
polygon(x= c(X[order(X)], rev(X[order(X)]) ), # both x and y go "out" in order;
y=c(L[order(X)], rev(U[order(X)])), # and then come "back in reverse order
col=rgb(1,0,0,0.3) ) # transparent pink.
> plot(X,Y, pch="+")
> abline(reg, col="red")
> polygon(x= c(X\[order(X)\], rev(X\[order(X)\]) ), y=c(L\[order(X)\],rev(U\[order(X)\])), col=rgb(1,0,0,0.3) )
我相信是完全相同的。尝试?多边形