[R] Using R as Shared Library
Thorsten Jolitz
tjolitz at googlemail.com
Sun Aug 12 20:21:21 CEST 2012
Dirk Eddelbuettel <edd at debian.org> writes:
> On 12 August 2012 at 07:56, Michael Weylandt wrote:
> | On Aug 12, 2012, at 6:09 AM, Thorsten Jolitz
> | <tjolitz at googlemail.com> wrote:
> | > Thorsten Jolitz <tjolitz at googlemail.com> writes:
> | > Let me reformulate my question (since I managed to make 'native' calls
> | > to C functions in libR by now):
> | > I still wonder whats 'in there' in libR - only the core C functions, or
> | > all the functions written in R itself too? And what packages are
> | > included?
> |
> | Just C functions.
>
> Moreover, many of these are marked 'non visible' and cannot be accessed. You
> probably want to consider
>
> a) the standalone R math library, available eg on Debian/Ubuntu as package
> r-mathlib which gets you a subset of R (distribution functions, random
> numbers, ...) for use in other programs, or
>
> b) the embedding API of R
>
> Both of these are documented in the 'Writing R Extension' manual that came
> with R.
>
> If you are interested in b), you may also want to look at the RInside project
> which makes embedding a lot easier. The simplest example is just
>
> #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);
> }
>
> which passes a string to the embedded R interpreter and calls an R function
> to display it. You can send full R objects back and forth thanks to Rcpp, and
> there are over a dozen examples included in the packages, as well as more
> advanced use of embedded R within the context of MPI (for parallel
> computing), Qt (for GUIs and much more) or Wt (for web applications).
Thanks, that looks very interesting indeed.
--
cheers,
Thorsten
More information about the R-help
mailing list