Hi Cesar,

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:

1. create an RInside instance "R" in the "main" function
2. pass that RInside instance by reference to the constructor for MyEvaluator 
and save it to a private member variable
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

Hope this helps,

Davor

On 2011-03-18, at 7:49 AM, CESAR PERNALETE wrote:

> 
> Hi Davor. 
> 
> Thanks for your response. Yes, the problem is the creation of  an embedded R 
> instance inside a method. 
> Attached there is a simplified example of the way i tried.   
> 
> As a context, i'm using NOMAD (http://www.gerad.ca/nomad/Project/Home.html), 
> an optimization tool where the constraints are functions created in R. These 
> constraints must be created in the method called eval_x. 
> 
> Please help. 
> 
> 
> 
> 
> 
> 
> Davor Cubranic <[email protected]>
> 17/03/2011 05:03 p.m.
> 
> Para
> CESAR PERNALETE <[email protected]>
> cc
> [email protected]
> Asunto
> Re: [Rcpp-devel] R Embedded in a class function
> 
> 
> 
> 
> 
> 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.
> 
> Davor
> 
> 
> On 2011-03-17, at 2:11 PM, CESAR PERNALETE wrote:
> 
> > 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? 
> > How would be? 
> > 
> > I tried to do it, and first argc, argv variables were expected. Then i 
> > assigned values to this variables in this way: 
> > 
> > const char *agv = "./main";  //No parameters are needed by the main 
> > function 
> > int agc = 1; 
> > RInside R(agc,&agv);  // create an embedded R instance 
> > 
> > In this case no error were found at compiling, but the embed didn't work. 
> > 
> > If some of you have some idea i would appreciate your help. 
> 
> 
> <embedRinAfunction.cpp>

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to