How to create 2x2 bar plot - with side by side pairwise bar in R

后端 未结 2 1196
独厮守ぢ
独厮守ぢ 2021-01-17 02:41

I have the following data:

  Method    Metric        E0        E1        E2        E4
1     M1 Precision 0.9661017 0.9622642 1.0000000 0.9655172
2     M2 Pr         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 03:25

    I realize you are trying to avoid external libraries, but ggplot was designed to make this easy.

    library(ggplot2)
    library(reshape2)
    
    gg <- melt(df,id=1:2)
    ggplot(gg) +
      geom_bar(aes(x=Method, y=value, fill=Metric), stat="identity",
               position="dodge")+facet_wrap(~variable)
    

提交回复
热议问题