I have an xts object with 4 columns. The first 3 columns are the mean and lower and upper confidence bounds for a proportion. The 4th column is the sample size. Since the scales are different, I thought it would make sense to plot the first 3 columns on one graph, and plot the 4th on a separate graph, right below it. Any suggestions on how to do this?
Here's code to build an xts object that's like the one I have:
startTime = Sys.time()
n = 10
d = seq(startTime,startTime+n*24*60*60,by="1 day")
a = sample(10000,length(d),replace=TRUE)
p = runif(length(d))
l = p/2
u = p+(p+1)/2
x= xts(p,d)
x = cbind(x,l,u,a)
colnames(x) = c("prop","low","high","size")
It's easy to do if you use plot.zoo. Something like this will get you started:
library(xts)
data(sample_matrix)
x <- as.xts(sample_matrix)
plot.zoo(x, screens=c(1,1,1,2))
There are tons of examples in ?plot.zoo; make sure to check them out.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With