Grouped bar chart in ggplot

后端 未结 1 1624
野趣味
野趣味 2021-01-23 10:02

For a sample dataframe:

df <- structure(list(year = c(1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 
3, 3, 4, 4, 4, 4, 4), imd.quintile = c(1, 2, 3, 4, 5, 1, 2, 3, 
         


        
相关标签:
1条回答
  • 2021-01-23 10:15

    I believe you are looking for something like this:

    library(ggplot2)
    
    ggplot(df ) + 
      geom_col(aes(x = year, y = average_antibiotic, group=imd.quintile, fill=imd.quintile), position = "dodge" )  
    

    0 讨论(0)
提交回复
热议问题