I have the following data frame, nothing to fancy about it.
df_bar<-data.frame(capacity = c(no[2],no[1]-no[2],max(df_l$load)-no[1]), type = c("Nuclear","Coal","Gas"),a = c("Optimal","Optimal","Optimal"))
I tried to create a stacked barplot via ggplot, but I also need to make sure that I have a specific order in that plot, with N being the closest to the axis and C the furthest. However, the simple code leads to this.
ggplot(df_bar, aes(y=capacity, x=a, fill=type)) +
geom_bar(position="stack", stat="identity")
How can I maybe alter the code so it respects the order I need?