title: How to extract every ggplot2 plot from a nested list
body: <p>It's often convenient to make large nested lists to keep track of plots created with <code>ggplot2</code>.</p>
  
  <p>For example, here's how I might store a handful of plots in a large list of plots, with sublists for topics and sub-topics.</p>
  
  <p><code>summary_plots</code></p>
  
  <ol>
  <li><code>$Demographics</code>
  
  <ul>
  <li><code>Demographics$Socioeconomic$Household_Income_Plot</code></li>
  <li><code>Demographics$Socioeconomic$Education_Plot</code></li>
  <li><code>Demographics$Age_Plot</code></li>
  </ul></li>
  <li><code>$Product_Usage</code>
  
  <ul>
  <li><code>Purchase_Frequency_Plot</code></li>
  <li>....</li>
  </ul></li>
  </ol>
  
  <p>How can I extract all of the <code>ggplot2</code> plot objects from this entire list? I'd like to be able to create a 'flat', one-level list containing all of the plots that were contained in the original list.</p>
  
  <hr>
  
  <p>Here's a quick example list:</p>
  
  <pre><code>generic_plot &lt;- ggplot(mtcars) + geom_point(aes(x = wt, y = mpg)) 
  
  summary_plots &lt;- list() 
  summary_plots$Demographics$Socioeconomic$Income &lt;- generic_plot 
  summary_plots$Demographics$Socioeconomic$Education &lt;- generic_plot 
  summary_plots$Demographics$Age &lt;- generic_plot 
  summary_plots$Product_Usage$Purchase_Frequency &lt;- generic_plot
  </code></pre>
  
  <p>The desired result would be the equivalent of creating a list like the following:</p>
  
  <pre><code>list('Demographics.Socioeconomic.Income' = generic_plot,
       'Demographics.Socioeconomic.Education' = generic_plot,
       ...)
  </code></pre>