I am trying to make a chart in ggplot but R has an odd sorting method. Instead of making it from the biggest number to lowest it sorts by first numer 1-9 so for example 100k is below 2. Could someone tell me how can I fix this?
ggplot(AWD,aes(Narodowosc, Dyscyplina, size= as.factor(Majatek.w..))) +
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 reproducible example:
structure(list(Imie.i.Nazwisko = structure(1:4, .Label = c("Aaron Donald",
"Aaron Rodgers", "Albert Pujols", "Alexis SĂ\241nchez ", "AndrĂ©s Iniesta ",
"Andre Drummond", "Anthony Davis", "Anthony Joshua", "Antoine Griezmann ",
"Ben Roethlisberger", "Blake Griffin", "Brandin Cooks", "Bryce Harper",
"Canelo Alvarez", "Carmelo Anthony", "Chris Paul", "Clayton Kershaw",
"Connor McGregor", "Cristiano Ronaldo", "Damian Lillard", "DeMar DeRozan",
"Deontay Wilder", "Drew Brees", "Dwight Howard", "Earl Thomas",
"Felix Hernandez", "Fernando Alonso", "Floyd Mayweather Jr.",
"Gareth Bale ", "Gennady Golovkin", "Gerard Piqué ", "Giancarlo Stanton",
"Giannis Antetokounmpo", "Gordon Hayward", "Harrison Barnes",
"J.D Martinez", "James Harden", "Joe Votto", "Jon Lester", "Jordan Spieth",
"Justin Rose", "Kei Nishikori", "Kevin Durant", "Kevin Love ",
"Khalil Macek", "Klay Thompson", "Kyle Lowry", "Kylian Mbappé ",
"Kyrie Irving ", "LeBron James", "Lewis Hamilton", "Lionel Messi",
"Luis SuĂ\241rez ", "Manny Machado", "Manny Pacquiao", "Marc Gasol",
"Matt Ryan", "Matthew Stattford", "Mesut Ă–zil ", "Miguel Cabrerra",
"Mike Trout", "Mohamed Salah", "Neymar Jr.", "Nick Foles", "Novak Djokovic",
"Paul George", "Paul Pogba", "Phil Mickelson", "Philippe Coutinho ",
"Rafael Nadal ", "Robert Lewandowski", "Roger Federer", "Rory McIlroy",
"Russel Westobrook", "Russel Wilson", "Sebastian Vettel", "Serena Williams",
"Sergio Ramos ", "Stephen Curry", "Steven Adams", "Tiger Woods",
"Toni Kroos ", "Trey Flowers", "Virat Kohli"), class = "factor"),
Narodowosc = structure(c(24L, 24L, 4L, 3L), .Label = c("Argentyna",
"Brazylia", "Chile", "Dominikana", "Egipt", "Filipiny", "Francja",
"Germany", "Grecja", "Hiszpania", "Indie", "Irlandia", "Japan",
"Kanada", "Kazachstan", "Meksyk", "Niemcy", "Nowa Zelandia",
"Polska", "Portugalia", "Serbia", "Szwajcaria", "Urugwaj",
"USA", "Wenezuela", "Wielka Brytania"), class = "factor"),
Dyscyplina = structure(c(4L, 4L, 1L, 9L), .Label = c("Baseball",
"Boks", "Formula 1", "Futbol amerykanski", "Golf", "Koszykowka",
"Krykiet", "MMA", "Pilka nozna", "Tenis ziemny"), class = "factor"),
Majatek.w.. = structure(c(48L, 67L, 20L, 28L), .Label = c("105,000,000",
"109,000,000", "127,000,000", "23,000,000", "24,500,000",
"25,000,000", "25,100,000", "25,300,000", "25,400,000", "25,500,000",
"25,600,000", "25,800,000", "26,300,000", "26,400,000", "26,600,000",
"27,000,000", "27,200,000", "27,400,000", "27,800,000", "28,000,000",
"28,400,000", "29,000,000", "29,200,000", "29,800,000", "30,000,000",
"30,200,000", "30,500,000", "30,700,000", "31,100,000", "32,400,000",
"32,800,000", "33,000,000", "33,800,000", "34,000,000", "34,300,000",
"34,600,000", "34,800,000", "35,000,000", "35,800,000", "37,300,000",
"38,000,000", "38,600,000", "39,000,000", "39,100,000", "40,200,000",
"40,300,000", "41,100,000", "41,400,000", "42,400,000", "43,200,000",
"43,300,000", "43,800,000", "44,000,000", "44,500,000", "45,000,000",
"47,700,000", "48,400,000", "50,600,000", "52,500,000", "53,700,000",
"55,000,000", "60,000,000", "62,294,116", "65,400,000", "79,800,000",
"89,000,000", "89,300,000", "89,500,000", "93,400,000", "94,000,000",
"99,000,000"), class = "factor"), Wiek = c(28L, 36L, 39L,
31L), Stan.cywilny = structure(c(1L, 1L, 2L, 1L), .Label = c("wolny",
"zonaty"), class = "factor")), row.names = c(NA, 4L), class = "data.frame")