<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Cesar,<div><br></div><div>I don't know why your embed does not work, but I would suggest to rework your code a bit and follow the pattern used by Dirk in his Qt example:</div><div><br></div><div>1. create an RInside instance "R" in the "main" function</div><div>2. pass that RInside instance by reference to the constructor for MyEvaluator and save it to a private member variable</div><div>3. MyEvaluator::eval_x can work the same as now, except that it will begin at the line "R.parseEvalQ" since you already have the RInside instance</div><div><br></div><div>Hope this helps,</div><div><br></div><div>Davor</div><div><br><div><div>On 2011-03-18, at 7:49 AM, CESAR PERNALETE wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">
<br><font size="2" face="sans-serif">Hi Davor. </font>
<br>
<br><font size="2" face="sans-serif">Thanks for your response. Yes, the problem
is the creation of &nbsp;an embedded R instance inside a method. </font>
<br><font size="2" face="sans-serif">Attached there is a simplified example
of the way i tried. &nbsp;</font>
<br>
<br><font size="2" face="sans-serif">As a context, i'm using NOMAD (<a href="http://www.gerad.ca/nomad/Project/Home.html">http://www.gerad.ca/nomad/Project/Home.html</a>),
an optimization tool where the constraints are functions created in R.
These constraints must be created in the method called eval_x. </font>
<br>
<br><font size="2" face="sans-serif">Please help. </font>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<table width="100%">
<tbody><tr valign="top">
<td width="40%"><font size="1" face="sans-serif"><b>Davor Cubranic &lt;<a href="mailto:cubranic@stat.ubc.ca">cubranic@stat.ubc.ca</a>&gt;</b>
</font><p><font size="1" face="sans-serif">17/03/2011 05:03 p.m.</font>
</p></td><td width="59%">
<table width="100%">
<tbody><tr>
<td>
<div align="right"><font size="1" face="sans-serif">Para</font></div>
</td><td valign="top"><font size="1" face="sans-serif">CESAR PERNALETE &lt;<a href="mailto:pernaletec@pdvsa.com">pernaletec@pdvsa.com</a>&gt;</font>
</td></tr><tr>
<td>
<div align="right"><font size="1" face="sans-serif">cc</font></div>
</td><td valign="top"><font size="1" face="sans-serif"><a href="mailto:rcpp-devel@r-forge.wu-wien.ac.at">rcpp-devel@r-forge.wu-wien.ac.at</a></font>
</td></tr><tr>
<td>
<div align="right"><font size="1" face="sans-serif">Asunto</font></div>
</td><td valign="top"><font size="1" face="sans-serif">Re: [Rcpp-devel] R Embedded
in a class function</font></td></tr></tbody></table>
<br>
<table>
<tbody><tr valign="top">
<td>
</td><td></td></tr></tbody></table>
<br></td></tr></tbody></table>
<br>
<br>
<br><font size="2"><tt>If you have some specific code, that would help. If
you by "class function" you mean to ask "is it possible
to create an embedded R instance inside a method?", then the answer
is "yes". But there are several things you may be doing incorrectly,
and seeing your code would mean we can address the one that is the problem.<br>
<br>
Davor<br>
<br>
<br>
On 2011-03-17, at 2:11 PM, CESAR PERNALETE wrote:<br>
<br>
&gt; I need to embed an R function in a class function. I have seen in
all of the examples that the embed of R always is made in the main function.
It possible to do it in a class function? <br>
&gt; How would be? <br>
&gt; <br>
&gt; I tried to do it, and first argc, argv variables were expected. Then
i assigned values to this variables in this way: <br>
&gt; <br>
&gt; const char *agv = "./main"; &nbsp;//No parameters are needed
by the main function <br>
&gt; int agc = 1; <br>
&gt; RInside R(agc,&amp;agv); &nbsp;// create an embedded R instance <br>
&gt; <br>
&gt; In this case no error were found at compiling, but the embed didn't
work. <br>
&gt; <br>
&gt; If some of you have some idea i would appreciate your help. <br>
<br>
</tt></font>
<br><span>&lt;embedRinAfunction.cpp&gt;</span></blockquote></div><br></div></body></html>