I want to plot monthly percentage change of two error metrics (MAE, RMSE), but the ordering of the plots are not correct. They should go horizontally from top to bottom as H1, H2, H3, .. etc, and ending with H12 at the bottom right. In stead they go H1, H10, H11, H12 across the top (I assume because the first number after the H is a 1). Could someone show me how to fix this please?
The code is ...
library(ggplot2)
# dataset
metric=c(rep("MAE" , 12) , rep("RMSE" , 12) )
horizon=rep(c("H1" , "H2" , "H3", "H4", "H5", "H6", "H7", "H8", "H9", "H10", "H11", "H12") , 2)
Perc_Change=c(-24,-55,-40,0,0,-2,-22,-28,-12,-12,-2,-8,-15,-44,-37,0,0,3,-21,-28,-7,-15,3,-9)
data=data.frame(metric,horizon,Perc_Change)
# Faceting
ggplot(data, aes(y=Perc_Change, x=metric, color=metric, fill=metric)) +
geom_bar( stat="identity") +
facet_wrap(~horizon)


