<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 12 (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;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        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;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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>Hi all,<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I&#8217;ve been trying the following, with the main part ripped
from rcpp-quickref:<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp; SEXP dfr2Mat(SEXP dfr)<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp; {<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DataFrame df =
dfr;<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int* dm =
INTEGER( ::Rf_getAttrib( df, R_DimSymbol ) ) ;<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int rows = dm[0];<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int cols = dm[1];<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NumericMatrix
retMat (rows, cols);<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(int i = 0; i
&lt; cols; i++)<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NumericVector curcol = df(i);<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//NumericMatrix::Column
zzcol = xx( _, 1);<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NumericMatrix::Column cl = retMat.( _, i);<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
cl = curcol;<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return retMat;<o:p></o:p></p>

<p class=MsoNormal>&nbsp;&nbsp;&nbsp; }<o:p></o:p></p>

<p class=MsoNormal>When compiling this, I get some errors starting from the
line after the comment (i.e. line 64):<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>main.cpp: In function 'SEXPREC* dfr2Mat(SEXPREC*)':<o:p></o:p></p>

<p class=MsoNormal>main.cpp:64: error: invalid conversion from 'SEXPREC*' to
'int'<o:p></o:p></p>

<p class=MsoNormal>main.cpp:64: error:&nbsp;&nbsp; initializing argument 1 of
'typename Rcpp::Vector&lt;RTYPE&gt;::Proxy
Rcpp::Matrix&lt;RTYPE&gt;::operator()(int, int) [with int RTYPE = 14]'<o:p></o:p></p>

<p class=MsoNormal>main.cpp:64: error: conversion from 'double' to non-scalar
type 'Rcpp::MatrixColumn&lt;14&gt;' requested<o:p></o:p></p>

<p class=MsoNormal>main.cpp:65: error: no match for 'operator=' in 'cl =
curcol'<o:p></o:p></p>

<p class=MsoNormal>C:/Users/nisabbe/Documents/R/win-library/2.11/Rcpp/include/Rcpp/vector/MatrixColumn.h:40:
note: candidates are: Rcpp::MatrixColumn&lt;RTYPE&gt;&amp;
Rcpp::MatrixColumn&lt;RTYPE&gt;::operator=(Rcpp::MatrixColumn&lt;RTYPE&gt;&amp;)
[with int RTYPE = 14]<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>I suspect it has something to do with this underscore
syntax.<o:p></o:p></p>

<p class=MsoNormal>I compiled with the following statement:<o:p></o:p></p>

<p class=MsoNormal>g++ -I&quot;C:/PROGRA~1/R/R-211~1.1/include&quot;
-I&quot;C:/Users/nisabbe/Documents/R/win-library/2.11/Rcpp/include&quot; -O2
-Wall -c main.cpp -o main.o<o:p></o:p></p>

<p class=MsoNormal>And the version of rcpp I installed is 0.9.4 on the most
recent version of R.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Can anyone show me what is wrong here?<o:p></o:p></p>

<p class=MsoNormal>Besides the syntax problems, what I am doing here should
work, right?<o:p></o:p></p>

<p class=MsoNormal>I know there are non-Rcpp ways to get this done, but this is
just something to get me started.<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>And as an addendum: where can I find out how (not) to use
this underscore?<o:p></o:p></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<p class=MsoNormal>Nick Sabbe<o:p></o:p></p>

<p class=MsoNormal>--<o:p></o:p></p>

<p class=MsoNormal>ping: nick.sabbe@ugent.be<o:p></o:p></p>

<p class=MsoNormal>link: <span lang=NL><a href="http://biomath.ugent.be/"><span
lang=EN-US>http://biomath.ugent.be</span></a></span><o:p></o:p></p>

<p class=MsoNormal>wink: A1.056, Coupure Links 653, 9000 Gent<o:p></o:p></p>

<p class=MsoNormal><span lang=NL>ring: 09/264.59.36<o:p></o:p></span></p>

<p class=MsoNormal><span lang=NL><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=NL>-- Do Not Disapprove<o:p></o:p></span></p>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>