Reversed order after coord_flip in R

后端 未结 1 1079
天涯浪人
天涯浪人 2020-12-09 08:07

Data example from dbv:

  gender Sektion
1      m       5
2      m       5
3      w      3B
4      w      3B
5      w      3B
6      m       4
相关标签:
1条回答
  • 2020-12-09 08:49

    You can add scale_x_discrete with the limits argument to do this. You could simply write out the limits in the order you want, but that gets complicated when you have many factor levels. Instead, you can pull the levels of the factor from your dataset and take advantage of rev to put them in reverse order.

    It would look like: scale_x_discrete(limits = rev(levels(dbv$Sektion)))

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