<div dir="ltr">Well, here's a snippet from a much larger routine I used deep inside an implementation of kd-trees:<div><pre style="color:rgb(0,0,0)">  for (int i = 0; i < instances_df.size(); ++i) {
    const NumericVector& data_column = instances_df[i];
    for (int j = 0; j < training_instances.size(); ++j) {
      // Argument order changes here...
      instances[j][i] = data_column[training_instances[j]];
    }
  }</pre>To set expectations, training_instances can be very large indeed (ca. 1M).   The code is quite fast.</div><div><br></div><div style>(And sorry, Dirk -- yes, I really do have an access of the form x[i][j].  Mea culpa, etc.)</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 19, 2013 at 3:26 PM, Ken Williams <span dir="ltr"><<a href="mailto:Ken.Williams@windlogics.com" target="_blank">Ken.Williams@windlogics.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> From: John Merrill [mailto:<a href="mailto:john.merrill@gmail.com">john.merrill@gmail.com</a>]<br>
> Sent: Tuesday, February 19, 2013 5:24 PM<br>
> To: Ken Williams<br>
> Cc: Yan Zhou; Dirk Eddelbuettel; <a href="mailto:rcpp-devel@lists.r-forge.r-project.org">rcpp-devel@lists.r-forge.r-project.org</a><br>
<div class="im">> Subject: Re: [Rcpp-devel] Efficient DataFrame access by row & column<br>
><br>
</div><div class="im">> I'm a little puzzled by your question.  Could you use a reference instead of instantiating a new copy?<br>
<br>
</div>I would love to use a reference, but I don't know how.  That's in fact the essence of my question. =)<br>
<br>
Is there already some example code somewhere showing how to get reference to a DataFrame column without copying?  I must be just missing it.<br>
<div class="HOEnZb"><div class="h5"><br>
 -Ken<br>
<br>
<br>
________________________________<br>
<br>
CONFIDENTIALITY NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution of any kind is strictly prohibited. If you are not the intended recipient, please contact the sender via reply e-mail and destroy all copies of the original message. Thank you.<br>

</div></div></blockquote></div><br></div>