title: Formula notation in boxplot (graphics) vs bwplot (lattice)
body: <p>This has been nagging me since I posted an answer to <a href="https://stackoverflow.com/q/11495406/1270695">this question</a> yesterday.</p>
  
  <p>Consider the following data:</p>
  
  <pre><code>carpaint &lt;- data.frame(paint = c(rep(c("blue", "black", "red"), 
                                       times=3)),
                         car1 = c(100, 138, 123, 143, 112, 
                                  144, 343, 112, 334), 
                         car2 = c(111, 238, 323, 541, 328, 
                                  363, 411, 238, 313), 
                         car3 = c(432, 123, 322, 342, 323, 
                                  522, 334, 311, 452))
  </code></pre>
  
  <p>If I wanted to generate boxplots by color (ignoring secondary grouping by "car"), I can easily use the formula notation in <code>bwplot</code> from <code>lattice</code>.</p>
  
  <pre><code>library(lattice)
  bwplot(car1 + car2 + car3 ~ paint, data=carpaint)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ICUVA.png" alt="Lattice Output"></p>
  
  <p>However, to get a similar plot using <code>boxplot</code> from <code>graphics</code>, the formula notation is different, so I have to first convert the data to a long format and then plot, like this:</p>
  
  <pre><code>carpaint.l = reshape(carpaint, direction="long", varying=2:4, sep="")
  boxplot(car ~ paint, data=carpaint.l)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/zhO11.png" alt="Graphics Output"></p>
  
  <p><strong>The Question</strong>: Is there a way to get the same plot with <code>boxplot</code> from <code>graphics</code> without first reshaping the data, preferably using formula notation? (This is ignoring the fact that this might not even be the type of output the OP of the linked question had wanted--they still haven't commented on my answer or the question by @RomanLuštrik. I'm just trying to satisfy my curiosity and learn to understand formula notation better.)</p>
  
  <blockquote>
    <blockquote>
      <p><strong>Note</strong>: providing alternatives is definitely welcome, but I'm hoping that any answers also help me understand why some options are working and others are not. For instance, why does <code>boxplot(as.matrix(carpaint[, 2:4]) ~ carpaint$paint)</code> work but <code>boxplot(carpaint[, 2:4] ~ carpaint$paint)</code> does not. I find that strange because the documentation for <code>boxplot</code> has examples where they convert matrices to data frames before plotting even though it does not seem to be necessary.</p>
    </blockquote>
  </blockquote>