I have three variables and each one has a confidence interval, as follow
variable lowerci beta upperci
a 0.86471152 0.87615515 0.88759878
b 0.966626566 0.970159119 0.973691671
c 0.94946211 0.955502661 0.961543211
I want to see if they overlap (clearly they don't, but I want the graph).
How can I do this in R?
If all you want is a graph of the confidence intervals, try the following.
library(ggplot2)
ggplot(df1, aes(x = variable, y = beta, ymin = lowerci, ymax = upperci)) +
geom_pointrange()
Data.
df1 <- read.table(text = "
variable lowerci beta upperci
a 0.86471152 0.87615515 0.88759878
b 0.966626566 0.970159119 0.973691671
c 0.94946211 0.955502661 0.961543211
", header = TRUE)
In addition to @Rui Barradas answer, here is a code to make it with base graphics:
df <- read.table(text = "variable lowerci beta upperci
a 0.86471152 0.87615515 0.88759878
b 0.966626566 0.970159119 0.973691671
c 0.94946211 0.955502661 0.961543211
", header = TRUE, as.is = TRUE)
plot(df[, 3], pch = 19, cex = 2, ylim = range(df[, -1]))
for (i in c(1:nrow(df))) {
lines(c(i, i), c(df[i, 2], df[i, 4]))
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.