I took an interesting sample of ggplot here and remade it for my data
My data is excel file
`
col <- c("Low weight", "very low weight", "Extra Very Low weight", "Cesarean section", "premature")
> ORpos <- c(6.8, 4.5,0.4, 4.5, 3.9)
> CI1 <- c(0.6, 0.4, 0, 0.2, 0.4)
> CI2 <- c(74, 56, 32, 20, 2.4)
> ORneg <- c(4.8, 15, 6, 6, 4)
> CI3 <- c(0.6, 0.4, 0, 0.2, 0.4)
> CI4 <- c(56, 43, 21, 10, 5)
> md4 <- data.frame(col,ORpos, CI1, CI2, ORneg, CI3, CI4)
plot3 <- ggplot(md4, aes(x = col)) +
geom_col(
aes(y = Orp, fill = 'Orp')) +geom_text(aes(y=Orp, label = paste(Orp, " [", CI1," ; ", CI2, "]", sep = ""), hjust = -1))+
geom_col(
aes(y = -Orn, fill = 'Orn')) + geom_text(aes(y=-Orn, label = paste(Orn, " [", CI3," ; ", CI4, "]", sep = ""), hjust = 1))+
coord_flip() +
scale_y_continuous(limits = c(-30, 30))
plot3
But this is where my understanding of R ended completely.
my plot
- Why is order my variables in the plot not order as in the table ???
2 What to do to data labels would be on the right and left edges of the plot or at least exactly under each other