I'm looking for help to sort/order my geom_col() bar plot in Rstudio. Nothing I tried worked for me. Any help would be most appreciated.
This question was marked duplicate by Gregor, however, non of the answers to the question in the referenced link work here.
I have the following 3 column file with headers which I am trying to sort (I'm only showing the 1st 8 rows):
POPULATION EXCESS_ALLELE_MATCHES_WITH_MBUTI GROUP
Jordanian 1,059 W Asians
BedouinB 937 W Asians
Saudi 894 W Asians
GujaratiD 835 S/SC Asians
Druze 722 W Asians
Iran_Fars 704 W Asians
Pathan 660 S/SC Asians
Here is my R code which works fine, except I'm not able to sort:
test <- read.csv(file_name, sep="\t", stringsAsFactor = FALSE,
header = TRUE)
ggplot(test, aes(x=POPULATION, y=EXCESS_ALLELE_MATCHES_WITH_MBUTI, fill=GROUP)) +
geom_col() +
coord_flip()
Click below to see my outputted unsorted barplot