0

I would like to add error bars to a bulletgraph using geom_errorbar. However, I do not have the data but only the "numbers", i.e. the "ultimate values" per category and the calculated std.

I have been trying to add them in, somehow, but I keep on being stuck, not knowing how to add error bars with "self determined values".

Note: I know it is not ideal, but I have split my data in multiple datasets as this was the only way I could figure out how to make a good looking bullet graph.

Dataset_1: Individual, Percentage (Previous)

Dataset_2: Individual, Percentage (Current)

Dataset_3: Individual, std (Previous Score)

Dataset_4: Individual, std (Current Score)

ggplot() +
  geom_bar(data = Dataset_1, 
           aes(x = Individual, y = Percentage, fill = Choice), stat = "identity",
           position = "stack") +
  geom_bar(data = Dataset_2, 
           aes(x = Individual, y = Percentage), fill = Fair, width = .2,
           stat = "identity") + 
  scale_fill_manual(values = Choice) +
  coord_flip(expand = FALSE)  
stefan
  • 90,330
  • 6
  • 25
  • 51
Sky
  • 11
  • 1
  • 1
    It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. – stefan Jul 28 '22 at 06:07
  • 1
    This said: `geom_errorbar` works fine with pre-computed values, i.e. you could do something like `+ geom_errorbar(data = Dataset_1, aes(x = Individual, ymin = Percentage - std, ymax = Percentage + std), width = 0.2, position = "stack")`. – stefan Jul 28 '22 at 06:09

0 Answers0