问题描述
我有一张桌子。我想用这张表绘制条形图,所以下面可以看到数据:
MEASURE_ERROR_TS_MODEL<-structure(list(Model = structure(c(6L,8L,1L,9L,5L,7L,2L,3L,10L,4L),.Label = c("ARIMA","CART","CTREE","Ensamble_ML","Ensamble_SM","ETS","LM","STL","TBATS","XGBoost"),class = "factor"),RMSE = c(12.89,6.08,11.46,5.23,4.92,4.86,4.78,4.65,4.64,3.532698),MAE = c(11.79,4.7,8.57,4,4.09,2.97,3.05,2.84,2.208528),Approach = structure(c(2L,1L),.Label = c("Machine learning","Statistical modelling"),class = "factor")),row.names = c(NA,-10L),class = c("tbl_df","tbl","data.frame"))
所以下一步是将这些数据绘制到barplot中。为了做到这一点,我尝试使用此代码,但plot不像我想要的那样
gplot(data=MEASURE_ERROR_TS_MODEL,aes(x=Model,y=MAE,fill=Approach),palette = c("#0073C2FF","#FC4E07")) +
geom_bar(
stat="identity",position=position_dodge(),colour="black")
从下面的图表中您可以看到此条没有分组并且我想进行分组(例如,左侧的绿色条,右侧的红色条)。有人可以帮助我做到这一点吗?