Reputation: 489
PROBLEM
I have a few datasets with data that have been already processed and exported with the following structure:
set.seed(123)
library(dplyr)
tb <- tibble(group = rep(c("A", "B"), each = 5),
wkday = rep(c("Mon", "Tue", "Wed", "Thu", "Fri"), times = 2),
sta = sample(-3:2, size = 10, replace = T),
mid = sta + 2,
fin = sta + 5)
QUESTION
I want to produce plots that look like the image below. How can I produce a plot like this one using ggplot, ggpubr or any other R packages?
Upvotes: 1
Views: 186
Reputation: 1600
This should get you started:
library(ggplot2)
ggplot(tb, aes(x=wkday, y= mid, ymin= sta, ymax=fin, lower = sta, upper = fin, middle = mid, fill= group)) +
geom_boxplot(stat = "identity") +
geom_hline(yintercept=0, linetype="dotted")+
coord_flip()
Upvotes: 1