Real 1.5

Real is a c-based interface for connecting R to Prolog. See the documentation at doc/html/real.html for more information. There is also a paper doc/padl2013-real.pdf and a user's guide doc/guide.pdf, but they both refer to earlier versions of Real.

Real works on current versions of SWI and YAP. As of version 1.1 there is support for using Real on SWI web-servers.


This software can be distributed as GPL or Aristic 2.0, see prolog/


To install stable versions:


?- pack_intall( real ).

Yap install Yap itself with configure --with-R

See doc/guide.pdf for further details on stable versions.

Git access

To get the latest git version goto

git clone git://

To install developmental versions do:

SWI-Prolog (a)

Install last stable real with ?- pack_install( real ).

do ?- pack_rebuild( real ). % to force SWI to build from sources.

And then replace c/real.c, prolog/ and examples/ in the stable installation by the development version.

and do again:

?- pack_rebuild( real ).

SWI-Prolog (b) clone real into pl-devel/packages/real add this to your build script export EXTRA_PKGS="real" build SWI from sources as per usual
Yap replace $YAP/packages/real with the development version you downloaded and rebuilt Yap with

configure --with-R



?- [pack('pack/real/examples/for_real')]. ?- for_real.
Yap ?- [examples/for_real]. ?- for_real.

Nicos Angelopoulos and Vitor Santos Costa December, 2012.

Updates: Nicos Angelopoulos Dec, 2013 Mar, 2014 May, 2015 Jan, 2016

Prolog files

examples/for_real.plShow source
examples/pagerank.plShow source
examples/test_real.plShow source
examples/ws_hist/ws_hist.plShow source
pack.plShow source
prolog/  -- An interface to the R statistical software.Show source
<-/1If Rvar is an atom and a known R object, then print Rvar on R.Source
<-/2Pass Prolog data PLdata to Rvar.Source
<<-/1Nick name for r_remove( Rvar ).Source
<<-/2True iff Rv is a undefined R variable and Rv <- Expr succeeds.Source
r/1Nickname for <-(R).Source
r/2Nickname for <-(L,R).Source
r_call/2Construct and possibly call an R function.Source
r_char/2Wrap an atomic value with double quotes so it can pass as an R char type.Source
r_citation/2Although the original name was R..eal, when citating please use Real as the name for this library.Source
r_devoff/0Close the current plot devise without any reporting.Source
r_devoff_all/0Close all open devices.Source
r_is_var/1True if Rvar is an atom and a known variable in the R environment.Source
r_is_var/2True if Rvar is a term and a known variable in the R environment.Source
r_library/1Load Rlib while respecting prolog_flag/2 real_suppress_lib_messages.Source
r_remove/1Remove Rvar from R's workspace (<- remove(Rvar)).Source
r_serve/0Serves any R calls that are waiting on the thread queue.Source
r_start/0Start an R object.Source
r_started/1Unifies F with true if R has been started or false if not.Source
r_thread_loop/0Starts a loop that serves R calls received from <-/1 and <-/2 calls from other threads.Source
r_version/3Version and release Date (data(Y,M,D) term).Source
r_wait/0Currently only waiting for Return to be pressed.Source