I am trying to create a grouped boxplot in R. I have 2 groups: A and B, in each group I have 3 subgroups of 5 dimensions.
Below is a way to create a box, but if anyone has a better, shorter or simpler way, I would appreciate
A1 <- c(1,2,9,6,4)
A2 <- c(5,1,9,2,3)
A3 <- c(1,2,3,4,5)
B1 <- c(2,4,6,8,10)
B2 <- c(0,3,6,9,12)
B3 <- c(1,1,2,8,7)
DF <- data.frame(A1, A2, A3, B1, B2, B3)
boxplot(DF, col = rainbow(3, s = 0.5))
axis(side = 1, at = c(2,5), labels = c("A","B"))
legend("topleft", fill = rainbow(3, s = 0.5), legend = c(1,2,3), horiz = T)

How can I group (merge) the boxes in A and B correctly and fix the axis header with A and B simple when I tried?
I would like something like
