How draw the quartile curve in the image (Quantile curve).I’m running the code but it’s giving me errors.
> plot(NULL,NULL,xlim=dt,ylim=c(min(Q1),max(Q3)),
+ xlab="lambda",ylab="reflectance")
Error in plot.window(...) : invalid 'xlim' value
> lines(lambda,colMeans(ts),lwd=2,col="blue")
Error in colMeans(ts) : 'x' must be an array of at least two dimensionst`
Quantile curve](https://i.sstatic.net/JpjUsMW2.jpg)
library(zoo)
`x <- c(0.231,0.186,0.163,0.167,0.2,0.232,0.252,
0.268,0.272,0.273,0.269,0.255,0.224,0.181,0.162)
dt <- seq(as.Date("1995-01-01"), as.Date("1996-03-01"), by = "month")
ts <- zoo(x, dt)
print(ts)
library(xts)
ts <- xts(x, dt)
print(ts)`
## Quantiles from 0.75 to 0.025
`Q3 <- apply(ts,MARGIN=2,FUN=quantile,probs=0.75)
Q1 <- apply(ts,MARGIN=2,FUN=quantile,probs=0.25)`
## Plotting
`plot(NULL,NULL,xlim=dt,ylim=c(min(Q1),max(Q3)),
xlab="lambda",ylab="reflectance")`
## Confidence interval [0.25;0.75]
`polygon(x=c(lambda,rev(lambda)),y=c(Q1,rev(Q3)),col="grey",border=NA)`
## Average curve
`lines(lambda,colMeans(ts),lwd=2,col="blue")`