【发布时间】:2017-09-22 11:04:03
【问题描述】:
我正在尝试生成一个条形图(使用 ggplot2),其中包含沿 y 轴的位置估计数据和沿 x 轴的基本计数比例。我的数据结构如下:
Data <- data.frame(locations = c("A","B","C","D"...), estimates = c(200, 300, 400, 200...)
然后我使用 dplyr 根据估计来排列我的数据
library(dplyr)
Data <- Data %>% arrange(estimates)
然后我运行我的 ggplot2 代码
library(ggplot2)
ggplot(Data, aes(locations, weight = estimates))+
geom_bar()+
coord_flip()
但是结果图是这样的,条形图没有根据估计排序。
【问题讨论】: