Did you know ... Search Documentation:
Packs (add-ons) for SWI-Prolog

Package "rolog"

Title:Simple interface to R
Rating:Not rated. Create the first rating!
Latest version:0.9.20
SHA1 sum:d6dfa6539b01e9088306441c1af505f5f1422274
Author:Matthias Gondan <Matthias.Gondan-Rochon@uibk.ac.at>

Reviews

No reviews. Create the first review!.

Details by download location

VersionSHA1#DownloadsURL
0.9.20a0b82fb2279d23fbd5b52fd8e6f09c2777a1ada69https://github.com/mgondan/rolog
7c9092d9021bdc03f4f4f3f736a65e5e820dc6114https://github.com/mgondan/rolog
244b91c10553dfc214d0db5ef87b7b0cd0b2975d1https://github.com/mgondan/rolog
d6dfa6539b01e9088306441c1af505f5f14222741https://github.com/mgondan/rolog
7cc34523f3f8a4615469bedd337f3ed778b50ba82https://github.com/mgondan/rolog
0f73395c26a32e0e56b01c1b43e6daff8be76af81https://github.com/mgondan/rolog
3db84840462cd6383e7369d20b6c11bc89ad12804https://github.com/mgondan/rolog
64927a9009a66d30e9350bd0350d4f2dd3cac9b37https://github.com/mgondan/rolog
7dc5e7897e7a7c06786ab117af78f4c6fd9c40c22https://github.com/mgondan/rolog
14a44f858390a8e067a63fdd994e3194eab564099https://github.com/mgondan/rolog
9e32274cd7991467273cc6cef9a56925480c2b534https://github.com/mgondan/rolog
0.9.19f436356c552d08193dbbef2e8cdf6434137e67383https://github.com/mgondan/rolog
414e2384b68d6b470c5254c2abadf81f0debd3764https://github.com/mgondan/rolog
b5b690f515f773948e94e06ffc8be2df42d1b3722https://github.com/mgondan/rolog
2f7c1ae1422196b02a55c6fbe0f6559830e249c91https://github.com/mgondan/rolog
5fe42b23ec3576a14dbab5962a978c15e3104f521https://github.com/mgondan/rolog
46e79bc42c4aa41bdd2a2ac59f1e3877b3fb49208https://github.com/mgondan/rolog

rolog: Access SWI-Prolog from R. Access R from SWI-Prolog.

Access SWI-Prolog from R

As the name says, rolog = Prolog for R. The logic programming language Prolog was invented in the 1970ies by Alain Colmerauer, mostly for the purpose of natural language processing. Since then, logic programming has become an important driving force in research on artificial intelligence, natural language processing, program analysis, knowledge representation and theorem proving.

This R package connects to an existing installation of SWI-Prolog. SWI-Prolog (https://www.swi-prolog.org/) is an open-source implementation of the logic programming language Prolog. SWI-Prolog targets developers of applications, with many users in academia, research and industry. SWI-Prolog includes a large number of libraries for "the real world", for example, a web server, encryption, interfaces to C/C++ and other programming languages, as well as a development environment and debugger.

rolog supports the following installations of SWI-Prolog, with decreasing priority:

  • If the environment variable SWI_HOME_DIR is set, the respective installation is used.
  • If swipl.exe is found on the PATH, that one is used.
  • (Windows only): If SWI-Prolog is installed in the system, a respective entry is found in the registry.
  • R package rswipl that is an embedded SWI-Prolog runtime.

License

This R package is distributed under a BSD-2 simplified license (see the file LICENSE).

Installation

R> install.packages("rolog")

R> library(rolog)

R> once(call("check_installation"))

Does this output appear?

................................................ not present
Warning: See http://www.swi-prolog.org/build/issues/tcmalloc.html
Warning: library(bdb) .......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/bdb.html
Warning: library(jpl) .......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/jpl.html
Warning: library(pce) .......................... NOT FOUND
Warning: See http://www.swi-prolog.org/build/issues/xpce.html
Warning: Found 4 issues.
list()
attr(,"query")
[1] "check_installation"

Examples

This is a hello(world).

R> library(rolog)

Run a query such as member(X, [1, 2, 3]) with

R> `findall(call("member", expression(X), list(1L, 2L, 3L)))`

Sorry for the cumbersome syntax. At the moment, expression(X) encapsulates variables. The query returns bindings for X that satisfy member(X, [1, 2, 3]).

The second example builds the vignette with nice use cases in Section 4.

`rmarkdown::render(system.file("vignettes", "rolog.Rmd", package="rolog"), output_file="rolog.html", output_dir=getwd())`

You should find an HTML page in rolog.html of the current folder. Note that it includes equations with MathML, which look best in the Firefox browser.

Access R from SWI-Prolog

As the name says, rolog = R for Prolog. The R system is a programming language for statistical computing and data visualization. It has been adopted in the fields of data mining, bioinformatics and data analysis.

This Prolog pack connects to an existing installation of R. rolog supports the following installations of R, with decreasing priority:

  • If the environment variable R_HOME is set, the respective installation is used.
  • If R or R.exe is found on the PATH, that one is used.

License

This Prolog pack is distributed under a BSD-2 simplified license (see the file LICENSE).

Installation

R> install.packages("RInside")

?- pack_install(rolog).

?- use_module(library(rolog)).

Examples

?- r_eval(rnorm(3), X).

?- r_call(print(rnorm(3))).

Contents of pack "rolog"

Pack contains 71 files holding a total of 602K bytes.