title: nested figure using gglot2
body: <p>I would like some help to code a nested figure using gglot2. The figure is about participants' payoff over periods. There are 60 periods which were partitioned into 12 independent trials. The main reason is that in each trial the maximum payoff one can reach stays the same. An example I find from previous study is attached.</p>
  
  <p>Different from the example, there are 6 interaction conditions in my study: 2 (transparency vs no transparency) x3(no flexibility nor repair, flexibility and repair), so there should be 6 geom_lines in each trial from trial 1 to trial 12. The table head looks like this:</p>
  
  <pre><code>  trial period transparency    flexibility    repair    payoff  
    &lt;int&gt;  &lt;int&gt; &lt;chr&gt;           &lt;chr&gt;          &lt;chr&gt;      &lt;dbl&gt;    
  1     1      1 no transparency no flexibility no repair   21.2      
  2     1      1 no transparency flexbility     no repair   23.2      
  3     1      1 no transparency flexbility     repair      19.3     
  4     1      1 transparency    no flexibility no repair   15       
  5     1      1 transparency    flexbility     no repair   20.3      
  6     1      1 transparency    flexbility     repair      18.8    
  </code></pre>
  
  <p>the x_aes should be the 12 trials, then within each trial, there is a second layer (5 periods)</p>
  
  <p>the y_aes should be the payoff per period.</p>
  
  <p><a href="https://i.stack.imgur.com/3PVEC.png" rel="nofollow noreferrer">nested plots</a>
  <a href="https://i.stack.imgur.com/3PVEC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3PVEC.png" alt="enter image description here"></a></p>