0
year implicit explicit
2021 10 37
2020 13 19
2019 10 43
2018 15 28
2017 4 21

I am learning R and have been struggling with creating bar charts in ggplot. With the above table, I'd like to create a bar chart that has year on the x axis and has two columns each year (one for implicit and one for explicit). I've looked at several threads and have been unable to figure out how to organize the data to get the bar graph I want.

  • 1
    Welcome. df = your data frame. Try `library(tidyverse`; `df %>% pivot_longer(cols = 2:3) %>% ggplot(aes(year, value, fill = name)) + geom_col(position = "dodge")` – tjebo Jun 11 '22 at 17:21
  • the idea of this is to shape your data long, and then dodge by group. – tjebo Jun 11 '22 at 17:21

0 Answers0