0

Every time I run my code I get the error of breaks and labels not being the same length

I've tried re-writing the code multiple times but nothing seems to work. I'm also new to using Rstudio

denisondata %>% 
  group_by(genderid) %>% 
  mean_ci(race) %>% 
  filter(genderid != "NA") %>% 

  ggplot(., aes(x = genderid, y = mean, fill = genderid)) +
  geom_col() + 
  facet_wrap(~race) +
  labs(x = "Gender Identity", y = "Race") +
  scale_x_continuous(breaks = c(1, 2, 3, 4, 5), 
                     labels = c("White, Hispanic, Black, Asian, Other"), 
                     limits = ("White, Other")) +
  theme(text = element_text(family = "Garamond", size = 12), 
        legend.position = "blank")

I expected a bar graph to be created about race and gender identity

Z.Lin
  • 28,055
  • 6
  • 54
  • 94
Jade Johnson
  • 1
  • 1
  • 1
  • Welcome to Stack Overflow! Could you make your problem reproducible by sharing a sample of your data so others can help (please do not use `str()`, `head()` or screenshot)? You can use the [`reprex`](https://reprex.tidyverse.org/articles/articles/magic-reprex.html) and [`datapasta`](https://cran.r-project.org/web/packages/datapasta/vignettes/how-to-datapasta.html) packages to assist you with that. See also [Help me Help you](https://speakerdeck.com/jennybc/reprex-help-me-help-you?slide=5) & [How to make a great R reproducible example?](https://stackoverflow.com/q/5963269) – Tung May 10 '19 at 02:40
  • 4
    You defined your x-axis breaks as `c(1, 2, 3, 4, 5)` (vector with **5** numerical values), and labels as `c("White, Hispanic, Black, Asian, Other")` (vector with **1** character string). It should probably be something like `c("White", "Hispanic", "Black", "Asian", "Other")`. Ditto for your x-axis limits, which I don't think you should be specifying at all in this case. – Z.Lin May 10 '19 at 02:44

0 Answers0