I am trying to make a chart in ggplot but R has a stupid sorting method. Instead of making biggest number it sorts bu first numer 1-9 so for example 100k is below 2. Could someone tell me how can I fix this?
ggplot(AWD,aes(nationality, discipline, size = money)) +
geom_point() +
theme(text = element_text(size=25),axis.text.x = element_text(angle=90,
hjust=1, vjust=0.4))+
labs(title = "Roznica w wielkosci zarobkow sportowcow roznych dziedzin
dla kazdego panstwa", x="Reprezentowane panstwo", y="Rodzaj sportu",
fill="Poziom zarobow")
Here is the reproducible example:
AWD <- data.frame(name = c("Aaron Donald", "Aaron Rodgers", "Albert Pujols", "Alexis SA¡nchez"),
nationality = c("Argentyna", "Brazylia", "Chile", "Dominikana"),
discipline = c("Baseball", "Boks", "Formula 1", "Futbol amerykanski"),
money = c("41,400,000", "89,300,000", "100,000,000", "30,700,000"))
AWD$money <- as.factor(AWD$money)
Edit:
I took the liberty to cut down the reproducible example code & rename several variables. The resulting data.frame is identical to the original one with one exception, with the code being somewhat more readable. It also does not mess up my RStudio layout.
The exception is adding a value that illustrates the issue that happens when ggplot displays the factor.
The rename was mostly for the reason I do not speak Polish. It would take me time to write the used variables correctly each time. I will provide answer shortly, it should work with this edit as is. Otherwise will require some minor tweaking.