<div dir="ltr"><div><div>Hi all,<br><br></div>Can anyone please help me in this.<br><br></div>Thanks<br>Amit<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 9, 2014 at 9:05 PM, Amit Gupta <span dir="ltr"><<a href="mailto:amit.gupta@alpha-grep.com" target="_blank">amit.gupta@alpha-grep.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div><div><div><div>Hi All,<br><br></div>I am trying to integrate R in my C++ code . I was going through some test examples in /RInside/inst/examples/standard/. I am able to reproduce the results of example 7 on my machine<br><i>"txt = "m <- 1.23";<br>        double d1 = Rcpp::as< double >(R.parseEval(txt));<br>        std::cout << "d1 " << d1 << std::endl;"</i><br><br></div>But when I am trying to integrate into my codebase , I am getting stuck at the call of <b><i>Rcpp::as< double >(R.parseEval(txt));<br><br></i></b></div>To give you the complete details,<br><br></div>this is the code in my codebase(which is getting stuck)<br><i><br>std::string txt = "m <- 1.23;";<br>double d1 = Rcpp::as< double >(R.parseEval(txt));<br>std::cout << "d1 " << d1 << std::endl;<br><br></i></div><i>When I do gdb , follwing is the stack trace<br><br>(gdb) n<br>341        RInside R(0,NULL,true,true,false);<br>(gdb) n<br>345        std::string txt = "m <- 1.23;";<br>(gdb) n<br>349            double d1 = Rcpp::as< double >(R.parseEval(txt));<br><b>gdb) s<br>0x0000003a088e8770 in profil_counter () from /lib64/libc.so.6<br>(gdb) s<br>Single stepping until exit from function profil_counter,<br>which has no line number information.<br>RInside::parseEval (this=0x7fffffffdb20, line="m <- 1.23;") at RInside.cpp:379<br>379    RInside.cpp: No such file or directory.<br>    in RInside.cpp<br>(gdb) n<br>381    in RInside.cpp<br>(gdb) n<br>379    in RInside.cpp<br>(gdb) n<br>381    in RInside.cpp<br>(gdb) n<br><br>Program received signal SIGTRAP, Trace/breakpoint trap.<br>0x00002aaaab687dfe in RInside::parseEval () from /usr/local/lib64/R/library/RInside/lib/libRInside.so<br>(gdb) s</b><br><br><br></i></div><i>When I replace the above code with <br><br>std::string txt = "m <- c(1,2,3,4,5);"<br>              "print(mean(m));";<br>               R.parseEval(txt);<br><br></i></div><i>This code works perfectly printing the mean of the vector.<br><br></i></div><i><b>My guess is that the problem is coming somewhere in typecasting the output of R.parseEval to double etc</b>.<br><br></i></div><i>Can someone please look into this. Thanks<span class="HOEnZb"><font color="#888888"><br><br></font></span></i></div><span class="HOEnZb"><font color="#888888"><i>Amit<br></i></font></span></div>
</blockquote></div><br></div>