title: Create a recursive list from a list of vectors
body: <p>Suppose I've got the following list, which represents a directory structure :</p>
  
  <pre><code>&gt; pages &lt;- list("about.Rmd", "index.Rmd", c("stats", "index.Rmd"), c("stats", "substats", "index.Rmd"))
  &gt; pages
  [[1]]
  [1] "about.Rmd"
  
  [[2]]
  [1] "index.Rmd"
  
  [[3]]
  [1] "stats"     "index.Rmd"
  
  [[4]]
  [1] "stats"     "substats"  "index.Rmd"
  </code></pre>
  
  <p>I'd like to create a recursive version of this list, something that would look like this :</p>
  
  <pre><code>&gt; rpages &lt;- list("about.Rmd", "index.Rmd", stats=list("index.Rmd", substats=list("index.Rmd")))
  &gt; rpages
  [[1]]
  [1] "about.Rmd"
  
  [[2]]
  [1] "index.Rmd"
  
  $stats
  $stats[[1]]
  [1] "index.Rmd"
  
  $stats$substats
  $stats$substats[[1]]
  [1] "index.Rmd"
  </code></pre>
  
  <p>I've tried different ways to do it, but I fear I'm now lost in a sea of <code>lapply</code> and <code>sapply</code>.</p>
  
  <p>Thanks in advance for any hint.</p>