r_session


Interface to R executables.

This library facilitates interaction with the R system for statistical computing. It assumes an R executable in $PATH or can be given a location to a functioning R executable (see r_bin/1 and r_open/1 for details on how R is located). R is ran as a slave with Prolog writing on and reading from the associated streams. Multiple sessions can be managed simultaneously.

r_session works on current versions of SWI and Yap.
For a number of years r_session was distributed with SWI as library('R').

This library has been superseeded by pack(real), which provides a much faster and robust interface to R by embedding the R dynamic library in Prolog using the foreign library interface. Still, the process based approach can come handy:

Documentation about this pack is in doc/r_session.html and a simple demo is in examples/r_demo.pl.

install

SWI

r_session can be installed from within SWI using its package manager.

?- pack_install(r_session).

And then load with:

?- [library(r_session)].

examples

There are a number of examples in the file examples/r_demo.pl which also implements a run_all script.

?- [pack(r_session/examples/r_demo)].

?- edit( pack(r_sessoin/examples/r_demo) ).

?- r_demo.

docs

Also available in distribution directory doc/

sources

r_session

contact

We always welcome comments on use cases. Particularly, applications and publications that use this pack. We also welcome fixes and bug reports. For contact details see: contact

thanks

To Jan Wielemaker, SWI-Prolog developer, for including the pack in versions of SWI up to 7.1.28 (as library('R')).

author

Nicos Angelopoulos

---
London,
March, 2015