title: Calculating means with stat_summary for two different groupings and plotting in one plot
body: <p>I am having issues with plotting two calculated means using stat_summary in the same figure.</p>
  
  <p>I am using ggplot and stat_summary to plot means of a dataset that I grouped based on variable A. Variable A can have value 1,2,3,4. The same data also have variable B that can have value 1,2.
  So, I can make a plot with means of the data grouped after variable A, and I get 4 lines.
  I can also make a plot with means of the data grouped after variable B, where I get 2 lines.
  But how can I plot them in the same figure, so that I get 6 lines? I have made a somewhat similar example using the mtcars dataset:</p>
  
  <pre><code>library(ggplot2)
  mtcars$cyl &lt;- as.factor(mtcars$cyl)
  mtcars$vs &lt;- as.factor(mtcars$vs)
  mtcars
  
  plot1 &lt;- ggplot(mtcars, aes(x=gear, y=hp, color=cyl, fill=cyl)) +
    stat_summary(geom='ribbon', fun.data = mean_cl_normal, fun.args=list(conf.int=0.95), alpha=0.5) +
    stat_summary(geom='line', fun.y = mean, size=1)
  plot1
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/LkrER.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LkrER.png" alt="enter image description here"></a></p>
  
  <pre><code>plot2 &lt;- ggplot(mtcars, aes(x=gear, y=hp, color=vs, fill=vs)) +
    stat_summary(geom='ribbon', fun.data = mean_cl_normal, fun.args=list(conf.int=0.95), alpha=0.5) +
    stat_summary(geom='line', fun.y = mean, size=1)
  plot2
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/1CoKL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1CoKL.png" alt="enter image description here"></a></p>
  
  <p>So far I have the impression, that since I start with ggplot(xxx), where xxx defines the data and grouping, I can't combine it with another ggplot with another grouping. If I could initiate ggplot() without defining anything in the argument, but only defining data and grouping in the argument for stat_summary, I feel like that would be the solution. But I can't figure out how to use stat_summary like that, if even possible.</p>