No subject
Mon Nov 22 12:45:25 CET 2010
Rcpp::NumericMatrix M(n,n);
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
M(i,j) = i*10+j;
}
}
But for Rcpp::DataFrame, I only see constructor using SEXP, which to my
understanding, is to pass data back from R to C++.
Ideally, I would expect to be able to define C++ data structure for
data.frame's row and use vector<row_structure> to construct
Rcpp::DataFrame.
Thx.
-Wei
------=_NextPart_000_0421_01CB9C6C.57A89C60
Content-Type: text/html;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:x=3D"urn:schemas-microsoft-com:office:excel" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<meta name=3DGenerator content=3D"Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-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;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Courier New";
color:black;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";
color:black;}
span.EmailStyle19
{mso-style-type:personal;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@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=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3DEN-US link=3Dblue vlink=3Dpurple>
<div class=3DWordSection1>
<p class=3DMsoNormal>Sorry I am really new to this. So it might be =
a silly
question. <o:p></o:p></p>
<p class=3DMsoNormal>I would like to know if it is possible to create
Rcpp::DataFrame in C++ and pass it to R. <o:p></o:p></p>
<p class=3DMsoNormal>From example code, I can see for NumericMatrix, I =
can do
something like: <o:p></o:p></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:black'> Rcpp::NumericMatrix =
M(n,n);<o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:black'> </span><b><span =
style=3D'font-size:10.0pt;
font-family:"Courier New";color:#9C20EE'>for</span></b><span =
style=3D'font-size:
10.0pt;font-family:"Courier New";color:black'> (</span><span =
style=3D'font-size:
10.0pt;font-family:"Courier New";color:#208920'>int</span><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> i=3D0; =
i<n;
i++) {<o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:black'> </span><b><span
style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#9C20EE'>for</span></b><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> =
(</span><span
style=3D'font-size:10.0pt;font-family:"Courier =
New";color:#208920'>int</span><span
style=3D'font-size:10.0pt;font-family:"Courier New";color:black'> j=3D0; =
j<n;
j++) {<o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:black'> =
M(i,j) =3D i*10+j;<o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:black'> =
}<o:p></o:p></span></p>
<p class=3DMsoNormal><span =
style=3D'font-size:10.0pt;font-family:"Courier New";
color:black'> }<o:p></o:p></span></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>But for Rcpp::DataFrame, I only see =
constructor using
SEXP, which to my understanding, is to pass data back from R to =
C++. <o:p></o:p></p>
<p class=3DMsoNormal>Ideally, I would expect to be able to define C++ =
data structure
for data.frame’s row and use vector<row_structure> to =
construct
Rcpp::DataFrame. <o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal>Thx. <o:p></o:p></p>
<p class=3DMsoNormal>-Wei<o:p></o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
<p class=3DMsoNormal><o:p> </o:p></p>
</div>
</body>
</html>
------=_NextPart_000_0421_01CB9C6C.57A89C60--
More information about the Rcpp-devel
mailing list