The RInside package provides a few classes for seamless embedding ofR inside of C++ applications byrelying onRcpp.
Provided with the package itself are nine subdirectories withexamples: from more than a dozen basic command-line examples (indirectorystandard) to graphical user-interfaces (usingbothQt andWt), linear algebra withArmadillo andEigen,parallel computing with MPI to a sandboxed server, and (since release0.2.16) a simple (and more limited) interface for embedding insice Capplications.
The simplest example (modulo its header) isexamples/standard/rinside_sample0.cpp
#include<RInside.h>// for the embedded R via RInsideint main(int argc,char*argv[]){ RInside R(argc, argv);// create an embedded R instance R["txt"]="Hello, world!\n";// assign a char* (string) to 'txt' R.parseEvalQ("cat(txt)");// eval the init string, ignoring any returns exit(0);}TheQtexample directory produces this application for showing how to use R(to estimate densities) inside a C++ executable (providing the GUI):

The code is portable across operating systems. Similar, theWtexample directory contains this C++-based web application doing thesame:

TheRInside webpage has some more details.
Dirk Eddelbuettel, Romain Francois, and Lance Bachmeier
GPL (>= 2)
Initially created: Mon Feb 09 21:29:54 CST 2009
Last modified: Sun May 26 10:25:40 CDT 2024