Bryce Carson
2024-Oct-13 00:52 UTC
[Rd] Embedding R in other applications as a scripting language
I am subscribing to r-core because I am spending more and more time reading the R implementation itself, but in the meantime I would love to discuss the topic of embedding R (or linking against it) with more experienced C developers and people who've written C or C++ code for R packages. I have reached the stage where to make progress with embedding R in the target application, TIC-80 (see https://tic80.com/), I need to study how R is initialized in a finder detail. At the moment my plans for integrating R include bundling the recommended packages in addition to magrittr (more than that would be overkill for the integration). The most relevant information I have seen on embedding R in other applications *as a scripting language* comes from the tests/Embedding/index.html document included in the R sources. At the moment the Internet Archive is down while they deal with a DDOS attack (thankfully their data are safe), so I can't access the PostgreSQL + R documents linked to from there. No big matter. I'm not particularly versed in C myself, but I can read it well and I understand more each day I read the R implementation itself and expose myself to the actual usage of non-trivial C. I read *Narain Gehani's C: an Advanced Introduction* over the summer to familiarize myself with the aspects of the language which weren't transparent to me from studying other languages (Java, R, Emacs LISP, Python). Anyhow, if anyone has experience playing with this since it was more popular twenty years ago (as it seems) please reply! Regards, and thanks for all the pirate jokes. R! --- Bryce [[alternative HTML version deleted]]
Simon Urbanek
2024-Oct-13 20:13 UTC
[Rd] Embedding R in other applications as a scripting language
Bryce, embedding R varies from easy to very complex depending on what you want to do with it. If all you want is to evaluate R commands and get the result values then it is easy: you just initialize R with Rf_initialize_R() and use R_tryEval() to evaluate what you need (making sure you stay on the main thread). However, if you want to run the full event loop or even use the GUI elements then it gets more complicated - you can have a look at https://github.com/s-u/rJava/blob/master/jri/src/Rinit.c which is short enough to illustrate the entry points and purposes. If you are willing to use C++ then RInside is a nice package that wraps the R API in C++ classes for easier use: https://github.com/eddelbuettel/rinside simplifying it quite a bit. Cheers, Simon PS: this list is for the discussions on *development* of R itself, please consider using the R-help mailing list instead which is where users discuss the *use* of R in various scenarios.> On 13 Oct 2024, at 13:52, Bryce Carson <bryce.a.carson at gmail.com> wrote: > > I am subscribing to r-core because I am spending more and more time reading > the R implementation itself, but in the meantime I would love to discuss > the topic of embedding R (or linking against it) with more experienced C > developers and people who've written C or C++ code for R packages. > > I have reached the stage where to make progress with embedding R in the > target application, TIC-80 (see https://tic80.com/), I need to study how R > is initialized in a finder detail. At the moment my plans for integrating R > include bundling the recommended packages in addition to magrittr (more > than that would be overkill for the integration). > > The most relevant information I have seen on embedding R in other > applications *as a scripting language* comes from the > tests/Embedding/index.html document included in the R sources. At the > moment the Internet Archive is down while they deal with a DDOS attack > (thankfully their data are safe), so I can't access the PostgreSQL + R > documents linked to from there. No big matter. > > I'm not particularly versed in C myself, but I can read it well and I > understand more each day I read the R implementation itself and expose > myself to the actual usage of non-trivial C. I read *Narain Gehani's C: an > Advanced Introduction* over the summer to familiarize myself with the > aspects of the language which weren't transparent to me from studying other > languages (Java, R, Emacs LISP, Python). > > Anyhow, if anyone has experience playing with this since it was more > popular twenty years ago (as it seems) please reply! > > Regards, and thanks for all the pirate jokes. R! > > --- Bryce > > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >
Apparently Analagous Threads
- Embedding R in other applications as a scripting language
- Problems to compile examples of RInside
- Using RInside in Visual Studio 8.0 VC++.NET Program
- Runtime error when run a RInside program compiled by intel c++ on windows
- RInside, rcpp compilation problem