I am attempting to build a chart for some LDA scores I have generated from bacterial abundances.
Here an example of the data:
Taxa <- c('Bacilli', 'Firmicutes', 'Slackia', 'Clostridium')
Level <- c('Class', 'Phylum', 'Genus', 'Genus')
Status <- c('Patient', 'Patient', 'Control', 'Control')
LDA.score <- c(3.5,2.0,-1,-3)
Example <- data.frame(Taxa, Level, Status, LDA.score)
I use this code to make the chart:
ggplot(data=Example, aes(x=Taxa, y=LDA.score, fill=Status)) + geom_bar(stat="identity", position="identity") + coord_flip()
I'd like the bars to be in numerical order so that the bars are grouped into control and patient. However, the resulting bar chart is in alphabetical order according to the x axis.
I have attempted to use reorder() but this doesn't seem to work.
Any help would be appreciated.