title: How do I convert a hierarchical dataframe to a list in R?
body: <p>If I had a hierarchical dataframe like this:</p>
  <pre><code>level_1&lt;-c(&quot;a&quot;,&quot;a&quot;,&quot;a&quot;,&quot;b&quot;,&quot;c&quot;,&quot;c&quot;)
  level_2&lt;-c(&quot;flower&quot;,&quot;flower&quot;,&quot;tree&quot;,&quot;mushroom&quot;,&quot;dog&quot;,&quot;cat&quot;)
  level_3&lt;-c(&quot;rose&quot;,&quot;sunflower&quot;,&quot;pine&quot;,NA,&quot;spaniel&quot;,NA)
  level_4&lt;-c(&quot;pink&quot;,NA,NA,NA,NA,NA)
  df&lt;-data.frame(level_1,level_2,level_3,level_4)
  </code></pre>
  <p>How do I convert this to a list which orders according to the hierarchy, like this:</p>
  <pre><code>&gt; list
   [1] &quot;a&quot;         &quot;flower&quot;    &quot;rose&quot;      &quot;pink&quot;      &quot;sunflower&quot; &quot;tree&quot;      &quot;pine&quot;      &quot;b&quot;         &quot;mushroom&quot;  &quot;c&quot;        
  [11] &quot;dog&quot;       &quot;spaniel&quot;   &quot;c&quot;         &quot;cat&quot;      
  </code></pre>
  <p>So for in value in level 1, it list all level 2 values expanded across the other levels. Hopefully that makes sense?</p>
  <p>Thanks in advance!</p>