Search code examples
c++rcalllogistic-regression

Calling R functions from C++


I want to perform multinomial logistic regression [using glm()] and do some graphs [gplot()] in C++.

I'm not able to write a function for this kind of regression in C++, but maybe is possible to open R and call glm() function in order to performe it inside of C++, is it? how? I would appreciate any idea.

Thanks in advance!


Solution

  • Yes you can via the RInside project which provides you with a (very simple) class R which instantiates the R interpreter. You can then pass commands as (possibly multi-line) strings and evaluate via the REPL.

    There are numerous examples in the package itself, and on different blog posts. As it uses Rcpp extensively, it is also covered in one chapter of the Rcpp book.