error bar in bar graph - adjusted-wald Binomial Confidence Interval

I am trying to produce a bar graph showing the task completion rate for 4 tasks. There are 5 people in my sample. My data shows that all participants completed task 1,2, and 4. No one completed task 3.
I am trying to make a bar graph showing the completion in percentage with the error bar (90% adjusted-wald binomial confidence interval). Does anyone know how to do this?

Below is my code for the bar graph. I just need the code for the error bar.

# data

data <- data.frame(
  Rate = c(1,0,1,1)

p <- ggplot(data) +
    geom_bar( aes(x=Task, y=Rate), stat="identity", fill="salmon1", alpha=0.7) + 
  scale_y_continuous(labels = scales::percent_format())

mynamestheme <- theme(plot.title = element_text(face = "bold", size = (14)), 
                  axis.title = element_text(size = (13), colour = "black"),
                  axis.text = element_text(colour = "black", size = (10)))

p + theme_classic() + mynamestheme + labs(title = "Task Completion Rate (Confidence at 90%)") + theme(plot.title = element_text(hjust = 0.5)) + labs(y="Task Completion Rate", x = "Task ") 

I've created some fake data to give you an idea of how to add error bars. Basically you need some way to tell ggplot about the vertical position of the error bar end-points:

# Fake data
data = data.frame(
  Task = as.character(4:1),
  Rate = c(0.3, 0.4, 0.1, 0.6),
  Error = c(0.05, 0.03, 0.06, 0.04)

p <- ggplot(data, aes(x=Task, y=Rate)) +
  geom_col(fill="salmon1", alpha=0.7) + 
  geom_errorbar(aes(ymin = Rate - Error, ymax = Rate + Error),
                width=0.2) +
  scale_y_continuous(labels = scales::percent_format(),
                     limits=c(0,1), expand=c(0,0)) +


Therefore is there any uncertainty? (I'm wondering where confidence intervals come into the story)

Thank you so much! It works!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.