1

enter link description hereDummy Data Sheet

I'm having issues with getting my graphs to display error bars, even though I've copied and modified code that has worked just fine. This is the code and graph that is working:

    graph2 <- summary %>%
   filter(Accuracy == "FALSE") %>%
  ggplot(.) + aes(x = Author, y = mean_err, fill = reorder(Quality, -mean_err)) +
  geom_bar(stat = "summary", fun.y = "mean", position = "dodge") + 
  xlab("Race of Author") + ylab("Proportion Lure Reported") + labs(fill = "Text Quality") +
  theme(panel.grid.major = element_blank(), panel.grid.minor = 
  element_blank(),panel.background = element_blank(), axis.line = element_line(colour = 
  "black")) +
   geom_errorbar(aes(ymin= mean_err - se_error, ymax= mean_err + se_error), 
   position=position_dodge(width=0.9), width=.1) +  
   geom_text(aes(label=round(mean_err,digits=2)), position=position_dodge(width=.9), 
   vjust=5) + scale_fill_manual(values=wes_palette("GrandBudapest2"))```  
    

This prints out a working graph with error bars.

When I tried to modify the code to have it instead show the proportion of unsure answers reported, I used this code:

      filter(Accuracy == "TRUE") %>%
      ggplot(.) + aes(x = Author, y = mean_unsu, fill= Author) +
      geom_bar(stat = "summary", fun.y = mean, position = "dodge") + 
      xlab("Race of Author") + ylab("Proportion Unsure Reported")  +
      theme(panel.grid.major = element_blank(), panel.grid.minor = 
      element_blank(),panel.background = element_blank(), axis.line = element_line(colour = 
      "black")) +
       geom_errorbar(aes(ymin= mean_unsu - se_unsu, ymax= mean_unsu + se_unsu), 
       position=position_dodge(width=0.9), width=.1) +  
       geom_text(aes(label=round(mean_err,digits=2)), position=position_dodge(width=.9), 
       vjust=5) + scale_fill_manual(values=wes_palette("GrandBudapest2"))

I get this image with no error bars.

enter image description here

I'm very confused at what I'm doing wrong. I feel like it is probably something very simple.

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Ingralt
  • 11
  • 2
  • Can you include (dummy) data that can go into your ggplot2 code? Preferably the result after the `filter()` function, with the same column names and vector types. – teunbrand Apr 12 '21 at 08:57
  • Hey teunbrand, I added a google sheet of dummy data. The author refers to a manipulation of Race and the 1 indicates that was the answer given by that person. Hope this helps, if not, let me know as this is my first post. – Ingralt Apr 12 '21 at 19:51
  • I can't access the google doc. If your (dummy) data is less than 100 rows, the preferred way of sharing it is to copy the output of `dput(dummydata)` and paste it in your question. It may look ugly, but we can just copy that and drop it right in our R sessions. See for example https://stackoverflow.com/a/5963610/11374827 under the header 'Copying original data' for a better explanation. – teunbrand Apr 12 '21 at 19:57

0 Answers0