How to better create stacked bar graphs with multiple variables from ggplot2?

后端 未结 5 878
野趣味
野趣味 2020-12-15 11:24

I often have to make stacked barplots to compare variables, and because I do all my stats in R, I prefer to do all my graphics in R with ggplot2. I would like to learn how t

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-15 12:10

    Your first question: Would this help?

    geom_bar(aes(y=..count../sum(..count..)))
    

    Your second question; could you use reorder to sort the bars? Something like

    aes(reorder(Interest, Value, mean), Value)
    

    (just back from a seven hour drive - am tired - but I guess it should work)

提交回复
热议问题