Y-axis values don't match the continuous values of data R

338 Views Asked by At

I have used the same code for similar datasets but for some reason, it is not working for this one.

This is roughly what I get. (I hid the categorical variable names)

enter image description here

This is the code that I have been using:

library(tidyverse)
library(ggplot2) 

df%>%
  arrange(desc(round), measure) %>%
  mutate(concept = factor(concept, unique(concept))) %>%
  ggplot() +aes(x=concept, y=measure, fill=round)+
  geom_bar(stat="identity") +
  theme_minimal()+
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  scale_fill_manual(name="round", values = c("purple", "red")) +
  coord_flip()+ 
  geom_errorbar(aes(ymax=upper, ymin=lower),position=position_dodge(.9))

Here is a sample df

    structure(list(concept = c("ball", "camel", "wind", 
    "dog", "happy", "script", "condensation", "Marxism"), 
        measure = c(2.45, 3.2, 3.91, 3.94, 4.31, 3.63, 4.54, 4.55), upper = c(6.46, 
        6.11, 7.23, 7.9, 9.17, 11.23, 11.32, 15.3), lower = c(1.56, 
        0.79, 1.45, 1.02, 1.65, 1.31, 1.64, 3.07), round = c("One", 
        "Two", "Two", "Two", "Two", "Two", "Two", 
        "Two")), row.names = c(NA, -8L), class = "data.frame")
0

There are 0 best solutions below