1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
## RInside: Easy embedding of R inside C++ (and C)
[](https://github.com/eddelbuettel/rinside/actions?query=workflow%3Aci)
[](https://www.gnu.org/licenses/gpl-2.0.html)
[](https://cran.r-project.org/package=RInside)
[](https://cran.r-project.org/package=RInside)
[](https://packages.debian.org/sid/r-cran-rinside)
[](https://cran.r-project.org/package=RInside)
[](https://github.com/eddelbuettel/rinside)
### About
The RInside package provides a few classes for seamless embedding of [R](https://www.r-project.org) inside of
C++ applications by relying on [Rcpp](https://www.rcpp.org/).
### 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](https://www.qt.io/) and Wt), linear algebra with
[Armadillo](https://arma.sourceforge.net/) and [Eigen](https://eigen.tuxfamily.org/index.php?title=Main_Page), 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.
The simplest example (modulo its header) is [examples/standard/rinside_sample0.cpp](inst/examples/standard/rinside_sample0.cpp)
```c++
#include <RInside.h> // for the embedded R via RInside
int 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);
}
```
The [Qt example directory](https://github.com/eddelbuettel/rinside/tree/master/inst/examples/qt) 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](https://github.com/eddelbuettel/rinside/tree/master/inst/examples/wt)
contains this C++-based web application doing the same:

### See Also
The [RInside](https://dirk.eddelbuettel.com/code/rinside.html) web page has
some more details.
### Authors
Dirk Eddelbuettel, Romain Francois, and Lance Bachmeier
### License
GPL (>= 2)
|