I'm trying to plot a bar chart that shows the R2 value of two variables before and after treatment. I'd like to plot the red bar for "before" first then the blue one for "after" (i.e reverse of the image below)
Example code:
variable = c("stage", "stage", "type", "type")
R2 = c(3.25, 4.21, 5.66,8.90)
treatment = c("before","after", "before", "after")
df <- data.frame(cbind(variable, R2, type))
df$R2 <- as.numeric(df$R2)
p <- ggplot(data = df, aes(x = variable, y = R2, fill=treatment)) +
geom_bar(stat = "identity", position = dodge, color = "black") +
scale_fill_manual(values=c("#00BFC4", "#F8766D")) +
theme(axis.text = element_text(size=11), axis.title = element_text(size=13))