title: How to create a grouped boxplot in R?
body: <p>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?</p>
  
  <p>I'm tryng to create a grouped boxplot in R. I have 2 groups: A and B, in each group I have 3 subgroups with 5 measurements each.</p>
  
  <p>The following is the way that I constructed the boxplot, but if someone has a better, shorter or easy way to do, I'll appreciate</p>
  
  <pre><code>A1 &lt;- c(1,2,9,6,4)
  A2 &lt;- c(5,1,9,2,3)
  A3 &lt;- c(1,2,3,4,5)
  B1 &lt;- c(2,4,6,8,10)
  B2 &lt;- c(0,3,6,9,12)
  B3 &lt;- c(1,1,2,8,7)
  
  DF &lt;- 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)
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/nIWAb.png" rel="noreferrer"><img src="https://i.stack.imgur.com/nIWAb.png" alt="enter image description here"></a></p>
  
  <p>How can I group correctly (joint) the boxes in A and B, and fix the axis title to simple A and B as I tryed?</p>
  
  <p>I'd like something like</p>
  
  <p><a href="https://i.stack.imgur.com/jbFOD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jbFOD.png" alt="enter image description here"></a></p>