Multiple boxplots placed side by side for different column values in ggplot

前端 未结 3 1757
余生分开走
余生分开走 2020-12-30 13:40

I have read different posts like this and this but my problem has a small variation. I have a df like this

ID <- c(\"DJ45\",\"DJ46\",\"DJ47\",\"DJ48\",\"         


        
3条回答
  •  旧巷少年郎
    2020-12-30 14:02

    You can also use the gather function in the Tidyr package to shape the data:

    library(tidyr)
    
    df1 %>% 
      gather(MS, value, MS1, MS2, MS3, MS4, MS5, MS6) %>% 
      ggplot(aes(x = factor(Tool), y = value, fill = factor(Tool)))+
      geom_boxplot()+
      facet_wrap(~MS)
    

提交回复
热议问题