Can anyone help me with this problem when running R scripts from C/C++?
I am working on a C++ program that depends on an R package, using Rcpp and RInside to bridge the gap. While I can execute as many lines of R as I like by calling RInside::parseEvalQ() for each line, it would be more readable and more maintainable to put the R portion of the program in a .r script. Unfortunately, I can't quite get it to work.
The naive approach, calling parseEvalQ("source('foo.r')"), looks for a file foo.r located in the program's working directory, rather than the source or installation directory. This can lead to highly unpredictable behavior, depending on where the program is being called from. The only alternative I've been able to find is to give a hardcoded path to the file, which is a portability nightmare.
Does anyone know of a way to ensure that either
the embedded R session searches for files relative to the C++ executable it's embedded in, or
the compiler and/or preprocessor somehow accounts for the contents of a specific .r file during building?
The short appendix offers a very basic introduction to the C++language to someone already (at least somewhat) familiar with Rprogramming. Introducing all of C++in just a few pages is not really possible. Countless books have been written about the C++language since its inception in the early 1990s (and we will list a few at the end in a section on...
R esum e. Nous pr esentons dans ce document, un mod ele de programmation fond e sur l'approche ob-jet, l'approche r eactive e t l a c o m m unication par diiusion. Ce nouveau mod ele permet de d ecrire na-turellement les interactions pouvant appara^ entre les objets. Nous pr esentons ennn bri evement u n e impl ementation r ealis ee avec les langag...