I can't figure out how to solve this.
The code at the end of the post produces this plot:
How can I make it so that each year has one column per product group (food & tobacco, personal care, etc...)? That is 5 columns per year.
Many thanks!
library(janitor)
library(tidyverse)
library(dplyr)
# Format data
us_exp <- clean_names(USPersonalExpenditure)
us_exp <- USPersonalExpenditure %>% 
  as.data.frame() %>% 
  rownames_to_column(., "type")
us_exp <- us_exp %>% 
  pivot_longer(!type, names_to = "year", values_to = "count") %>% 
  as_tibble()
# ggplot
  
ggplot(us_exp) +
  aes(x = year,
      y = count,
      group = type,
      fill = type) +
  geom_col()
  theme_classic(base_family = "helvetica_regular") +
  theme(legend.position="bottom",
        text = element_text(size = 24)) +
  scale_fill_npg() +
  ggtitle("...") +
  xlab(NULL) +
  ylab(NULL)

 
    
