title: Appending to elements within an Rcpp List
body: <p>Possibly a stupid question, but I've hunted around a lot for an answer and been unable to find one:</p>
  
  <p>I'm trying to write a file reader, a la <code>fread</code> or <code>read.delim</code> but implemented in C++ and connected to R via Rcpp. The easiest way to do this and have it output a data.frame is have it produce a <code>List</code> of vectors - one for each column - and set the class to <code>data.frame</code></p>
  
  <pre><code>List foo;
  foo.push_back(column);
  foo.attr("class") = "data.frame";
  return foo;
  </code></pre>
  
  <p>Simple enough, and I've done it before. Unfortunately:</p>
  
  <ol>
  <li>The file(s) I want to read in can have a varying number of fields;</li>
  <li>This model only works elegantly if you're reading from the file column-wise, while actual files tend to be read row-wise.</li>
  </ol>
  
  <p>So, the answer is to be able to define foo and then, for each row I read in, push_back() a field on to each of foo's underlying vectors:</p>
  
  <pre><code>List foo(1);
  foo[0].push_back("turnip");
  </code></pre>
  
  <p>Unfortunately I can't work out how to do that: it doesn't appear that a List's member vectors can be pushed_back() to, since this results in the error "Rcpp::Vector&lt;19>::Proxy has no member named push_back()"</p>
  
  <p>So, my question: is there any way to append to a vector within an Rcpp list? Or is my only option to read the file in column-by-column, appending the resulting vectors to "foo", and bite the performance cost that's going to result from having to iterate through it [number of columns] times instead of once?</p>
  
  <p>Hopefully this question is clear enough. Happy to answer any questions.</p>