You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The RInside package provides a few classes for seamless embedding of R inside of
C++ applications by relying on Rcpp.
Examples
Provided with the package itself are nine subdirectories with examples: from more than a dozen basic command-line examples (in directory
standard) to graphical user-interfaces (using both Qt and Wt), linear algebra with
Armadillo and Eigen, parallel computing with MPI to a
sandboxed server, and (since release 0.2.16) a simple (and more limited) interface for embedding insice C applications.
#include<RInside.h>// for the embedded R via RInsideintmain(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 returnsexit(0);
}
The Qt example 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, the
Wt example directory
contains this C++-based web application doing the same: