r - 使用 ggplot 对两个变量进行排序并重新排序
问题描述
解决方案
We can use paste
ggplot(df_full_short,aes(x=reorder(unit, paste(var1, var2)), y=dev)) +
...
Or may be change the unit
levels
based on the 'var1', 'var2'
library(dplyr)
df_full_short %>%
arrange(var1, var2) %>%
mutate(unit = factor(unit, levels = unique(unit))) %>%
ggplot(aes(x = unit, y = dev)) +
...
推荐阅读
- android - 错误重复 jar 条目 [android/support/v4/media/MediaBrowserCompat$a.class]
- ios - 选择时更改单元格视图颜色。并在选择另一个单元格时将其更改回来
- java - 时区之间的转换导致意外行为
- google-cloud-platform - 在通过谷歌提供的模板创建的谷歌数据流作业中使用私有 ip
- mysql - MySQL 存储过程中 UPDATE、REPEAT 和 LIMIT 的错误使用
- c# - ASP.NET MVC 自定义验证错误消息
- gitlab - 如何通过手动单击或提交消息触发作业
- html - 使文本和下拉列表一起内联引导
- sql - 触发代码在 oracle 中不起作用以避免重复数据
- python - Python、Keras、张量流