在利用ggplot2画柱图时,如何将柱图的显示按照升序或者降序排列,我的代码如下
word_cors %>%
filter(item1 %in% c("creat","sustain","develop","global","economi","tech")) %>%
group_by(item1) %>%
top_n(20) %>%
ungroup() %>%
mutate(item2 = reorder(item2, correlation)) %>%
ggplot(aes(item2,correlation,fill=item1)) +
geom_bar(stat = "identity",width = 0.8) +
labs(y="Correlation",x="Words")+
theme(legend.position = "none")+
facet_wrap(~ item1, scales = "free_y") +
coord_flip()
在这个代码中,我要显示与"creat","sustain","develop","global","economi","tech"这些单词相关性最高的前20个次,但是柱图完成后并不是按照先关系数的降序排列的,我应该如何修改代码才能在柱图中将先关系数按降序排列,感谢


雷达卡




京公网安备 11010802022788号







