<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">That may be a good option if I’m willing to make at least one copy, right at the beginning, to create the NumericMatrix. I’d prefer to even avoid that copy
if possible, but if it must be, it must be.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It performs somewhere between the other two options:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">
<a href="https://gist.github.com/kenahoo/4991485">https://gist.github.com/kenahoo/4991485</a><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Ken<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Kevin Ushey [mailto:kevinushey@gmail.com]
<br>
<b>Sent:</b> Tuesday, February 19, 2013 6:07 PM<br>
<b>To:</b> Ken Williams<br>
<b>Cc:</b> John Merrill; rcpp-devel@lists.r-forge.r-project.org<br>
<b>Subject:</b> Re: [Rcpp-devel] Efficient DataFrame access by row & column<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Another thing worth thinking about: perhaps the easiest way to side-step the issue is to work with a NumericMatrix rather than a DataFrame. At least, from the example you gave, it sounds like a container where you have the expectation that
each column is a NumericVector of equal length.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">If you can make the switch to NumericMatrix, then you can generate and operate with row/column views, e.g. NumericMatrix::Row and NumericMatrix::Column, which will generate references to rows / columns and hence avoid copying. (These are
generated whenever you do e.g. x(i, _) or x(_, i) on a NumericMatrix x).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-Kevin<o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Tue, Feb 19, 2013 at 3:26 PM, Ken Williams <<a href="mailto:Ken.Williams@windlogics.com" target="_blank">Ken.Williams@windlogics.com</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal"><br>
<br>
> From: John Merrill [mailto:<a href="mailto:john.merrill@gmail.com" target="_blank">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" target="_blank">
rcpp-devel@lists.r-forge.r-project.org</a><o:p></o:p></p>
<div>
<p class="MsoNormal">> Subject: Re: [Rcpp-devel] Efficient DataFrame access by row & column<br>
><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">> I'm a little puzzled by your question. Could you use a reference instead of instantiating a new copy?<o:p></o:p></p>
</div>
<p class="MsoNormal">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.<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><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>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><o:p></o:p></p>
</div>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</body>
</html>