How to create a grouped boxplot in R?

后端 未结 3 1486
离开以前
离开以前 2020-12-06 05:46

I want to merge the three datasets grouped and obtain a graph with only two boxes, 1 for A and 1 for B. Can you suggest how to get that?

I\'m tryng to create a group

3条回答
  •  [愿得一人]
    2020-12-06 06:17

    Using base R, I think @r2evans solution is the best. However, an easier fix to the code in the question is by using the option xaxt="n":

    boxplot(DF, col = rainbow(3, s = 0.5), at = c(1:3,5:7), xaxt = "n")
    axis(side = 1, at = c(2,6), labels = c("A","B"))
    legend("topleft", fill = rainbow(3, s = 0.5), legend = c(1,2,3), horiz = T)
    

    This adds more flexibility in formatting the axis.

提交回复
热议问题