So I'm trying to make a bar chart, it comes out fine, but in the wrong order. under "Patient" I have titles; pre, 1 to 3, 4 to 6, 7 to 9, 10 to 12, 13 to 18, 19 to 24 and 24+ . I want the bars in that exact order, but they are coming up in a completely different order.... any idea how I would keep my data in the order above? Here is the code I'm using
library(readr)
library(ggplot2)
ave_gini_and_shannon_timepoint_groups <- read_csv("~//.R/ave gini and shannon timepoint groups.csv")
ggplot(ave_gini_and_shannon_timepoint_groups, aes(x=Patient, fill=Patient, y=Shannon_T)) +
geom_bar(stat = "identity", width=0.4) +
scale_fill_hue(c = 40) +
theme(legend.position="none")
TIA!
I've tried using reorder, but it isn't working.