title: Stacked bar chart with group by and facet
body: <p>My data looks like this:</p>
  
  <pre><code>system  operation_type  prep_time   operation_time
  A       x               0.7         1.4
  A       y               0.11        2.3
  A       z               1.22        6.7
  B       x               0.44        5.2
  B       y               0.19        2.3
  B       z               3.97        9.5
  C       x               1.24        2.4
  C       y               0.23        2.88
  C       z               0.66        9.7
  </code></pre>
  
  <p>I would like to have a stacked chart on prep_time and operation time that gives me total_time grouped by system and then faceted by operation_type.</p>
  
  <p>My code looks like this for now.</p>
  
  <pre><code>library(ggplot2)
  
  df &lt;- read.csv("test.csv", strip.white=T)
  plot &lt;- ggplot(df, aes(x=system,y=(prep_time+operation_time))) + geom_bar(stat="identity") + facet_grid(.~operation_type)
  </code></pre>
  
  <p>The output I get is
  <a href="https://i.stack.imgur.com/LrIZM.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LrIZM.jpg" alt="enter image description here"></a></p>
  
  <p>What I need is a distinction in bar that shows what part of the total_time is prep_time and what is operation_time. I thought of adding a legend and having different colors for prep_time and operation_time but I cannot figure out how I can do that.</p>