Geom_bar:如何重新排列条形以降序排列

问题描述 投票:0回答:0

我正在处理有关大学分数的数据,并且有一个分组的水平条形图显示每所大学的各自评级。但是,我想让我的条形图按降序排列 - 我该怎么做?

代码:

ratings <- read.csv("senior_expert_ratings_tall.csv", stringsAsFactors = T)
ggplot(data=ratings, aes(x=Assessment,y=Rating,fill=Agency)) +
  theme_minimal() +
  geom_bar(position="dodge",stat="identity") + 
  labs(title="Expert Ratings of Key Universities",
       subtitle="The INORMS Research Evaluation Group, in partnership with rankings\nexpert Dr Richard Holmes, produced a rating of six key global university\nrankings in 2021. Using 20 community-sourced criteria across four main\nthemes (good governance, rigour, transparency, and measure what matters)\nexperts were invited to assess the ranking agencies both qualitatively and\nquantitatively. The assessment found that all rankers fell short of the community\nexpectations, with the higher-profile agencies faring worse than others.",
       caption = "Figure 2: Global university ranking agencies assessed by international experts\nagainst criteria including transparency and rigour.") +
  theme(panel.grid.minor.x = element_blank(),
        panel.grid.minor.y = element_blank()) +
  theme(plot.caption = element_text(hjust=0)) +
  theme(plot.subtitle = element_text(size=8)) +
  theme(axis.title.x = element_blank()) +
  theme(axis.title.y = element_blank()) 

Output graph

r ggplot2 geom-bar
© www.soinside.com 2019 - 2024. All rights reserved.