Call R Script from C code

Is there a way to call R-Script inside C code?

I found R Api for C (chaper 6. of the guide "Writing R-Extensions"), but, as I understand it, this "only" allows us to name the C-implementation of R. Because of this, I could call R-Script through the shell, but there is no solution for me, since this does not allow the data to be transferred correctly (at least not if I do not want to write the data to a Csv file or something like that),

Is there an easy way to use the RC parser in advance?

+4
source share
2 answers

Is there any reason you don't want to embed it? This is covered in this question: R of C - The Simplest Possible Helloworld ...

+3
source

I found that this works to run Rscript in C ++ for Mac:

string r_command = "/usr/local/bin/RScript --vanilla /Users/<enter file path here>/your_script.R \"" + argument_1 + "\" " + "\"" + argument_2 + "\""; system(r_command.c_str()); 

You can also pass variables into arguments. Beware of shoots. Everything can become complicated.

0
source

Source: https://habr.com/ru/post/1307369/


All Articles