title: Write list to a text file, preserving names, R
body: <p>I want to write a list to a text file, preserving the names.</p>
  
  <p>This is similar to <a href="https://stackoverflow.com/questions/3044794/r-print-list-to-a-text-file">R: Print list to a text file</a> but with names which I want to print out also, at the start of each line:</p>
  
  <pre><code>&gt; print(head(mylist,2))
  $first
  [1] 234984  10354  41175 932711 426928
  $second
  [1] 1693237   13462
  
  mylist.txt
  first   234984  10354  41175 932711 426928
  second  1693237   13462
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Many thanks.</p>