I have a stacked bar chart providing the proportion of visa case status (certified or denied) by world region. Here is the summary table that is used for the plot, as well as the code for the plot itself:
#Summarize grouped dataframe by World Region and Case Status Coded (by number
of records and proportion)
summ_worldreg <- df_nona_worldreg %>% group_by(World.Region,
CaseStatusCodedFactor) %>% summarise(n=n()) %>% mutate(proportion = n/sum(n))
Output of summ_worlreg:
World.Region CaseStatusCodedFactor n proportion
<fct> <fct> <int> <dbl>
1 Australia and New Zealand Denied 125 0.0628
2 Australia and New Zealand Certified 1865 0.937
3 Carribbean Denied 337 0.187
4 Carribbean Certified 1467 0.813
5 Central America Denied 2423 0.238
6 Central America Certified 7762 0.762
7 Central Asia Denied 31 0.0861
8 Central Asia Certified 329 0.914
#Plot 100% Stacked Bar Graph showing distribution of Case Status by World
Region
worldreg_case_bar <- ggplot(summ_worldreg, aes(x = summ_worldreg$World.Region,
y = summ_worldreg$proportion, fill = summ_worldreg$CaseStatusCodedFactor)) +
geom_bar(stat = 'identity')
Image of Plot: 100% Stacked Bar Chart - Case Status by World Region
I am wanting to order the factors (World Regions) in this bar chart so that the proportion of 'denied' records increases from left to right. In other words, I want the world region with the lowest proportion of 'denied' records to be on the far left and the world region with the highest proportion of 'denied' records to be on the far right.
Any insight on how to order this bar chart would be much appreciated. Thanks!