0

How can I rearrange my axis, I created a grouped bar chart using ggplot, and my graph is suppose to show the values in increasing orders but the numbers given in the y-axis is all scattered and is not in order. I tried to use various functions but It failed. I also have some inputs that are NA in the Percentage coloumn.

My data sample is:

Countries Objectives Percentage
Asia R 37,5
Asia C 18,8
Africa R 39,7
Africa C 22,4
N.America R 65,2
N.America C 26,1

My list goes on and the code I used to make the graph is

ggplot(mydata, aes(factor(Objectives), Percentage, fill = Countries)) + 
  geom_bar(stat="identity", position = "dodge") + xlab("")

Thanks for your help in advance

enter image description here

  • If you want to set the order of bars, you need to order the levels of the factor. The `reorder()` function is helpful for that and is described in many existing answers. The problem is also your Percentage column does not appear to be numeric. It's better to share a `dput()` to verify. When you read your data in, make sure you tell R to use `,` as a decimal indicator rather than the default `.` so that your numbers are imported as numeric values (not character values). – MrFlick Aug 15 '21 at 21:43

0 Answers0