I am trying to replicate a box plot using R ggplot. However, I am having difficulties adding error bar especially with upper and lower horizontal lines. Also in my graph the jitter points are spread unevenly. Here is my code and the output
survey <- data.frame(sample=rep(c("sample1","sample1", "sample1", "sample1", "sample1", "sample1", "sample1", "sample1", "sample1", "sample1", "sample2", "sample2", "sample2", "sample2", "sample2", "sample2", "sample2", "sample2", "sample2", "sample2"),1),
values=c(200, 100, 150, 175, 145, 50, 75, 60, 45, 56, 300, 200, 150, 100, 125, 25, 50, 75, 45, 35))
survey
library(ggplot2)
p1 <- ggboxplot(survey, x = "sample", y = "values", color = "black", fill = "sample",
palette =c("grey", "darkgrey"),
width = 0.3, add = c("mean_se", "jitter"),
add.params = list(size = 0.9))
p1
I would like to generate two different types of boxplots, as presented in these example boxplots. Could anyone help in generating these boxplots. Thank you