I have to sort alphabetically the name of the species that appear in the data frame, but in turn, they have to be ordered by the category assigned in the "Vuln" column. In my code, the first part is resolved, but I can not group the appearance of the species in the figure by its category.
I tried that ggplot used the order of the data frame data, but I did not get it. My knowledge about R is limited by the little time I have been using it, basically I learn based on trial and error.
df1 <- read.csv(file=paste(di,"/specieorder.csv", sep=""), header=TRUE, sep=";")
# Change order (allphabetically) to improve the plot
df1 <- within(df1, Specie_ord <- ordered(Specie, levels=rev(sort(unique(Specie)))))
df1<- df1[df1$Group.1!=' ', ]
str(df1)
df1$Zone <- as.factor(df1$Zone)
library(ggplot2)
p <- ggplot(df1, aes(Zone,Specie_ord)) +
geom_point(aes(size=x), shape=15, col='darkred') +
scale_size('Number\nof\nRecords')+
theme_bw() +facet_grid(.~Fire) +
xlab('Zone') + ylab('Species')
p + ggtitle("Abundance by species") +
theme(plot.title = element_text(face="bold", size=12))
I attach the file with the data in .csv format "delimited by commas" https://drive.google.com/open?id=1cOZv39XkxuM64LLXYiLTd_ujUSKeRnPL