rErlang
installation prerequisites
erlang
If using Ubuntu packages, erlang-dev is needed for erl_interface.
R
$ sudo apt-get install r-base
To install R packages from CRAN, the CRAN mirror to use must be set. Change the url in doc/dot-Rprofile as desired, and then:
$ cp doc/dot-Rprofile ~/.Rprofile
For the moment at least, R packages should be installed from within R, rather than via rErlang. e.g.:
$ R > install.packages("forecast") >
edit c_src/Makefile
Ensure the paths at the top of the file are correct. Make sure the erl_interface version number is correct.
ERL_BASE := /usr/lib/erlang/lib/erl_interface-3.7.13 R_INCLUDE_DIR := /usr/share/R/include R_HOME := /usr/lib/R
build
$ make
run
Example usage:
$ ./start_erl_node.sh
Erlang/OTP 18 [erts-7.0] [source] [64-bit] [async-threads:10] [kernel-poll:false]
Eshell V7.0 (abort with ^G)
(node01@localhost)1> eri:start().
"."
true
(node01@localhost)2> eri:connect().
{ok,0}
(node01@localhost)3> eri:eval("x <- c(12,34,56,78,90)").
{ok,'REALSXP',[12.0,34.0,56.0,78.0,90.0]}
(node01@localhost)4> eri:eval("mean(x)").
{ok,'REALSXP',[54.0]}
(node01@localhost)5> eri:stop().
stop
Note that:
- This is an interactive session. Command #3 sets a variable x, then command #4 uses that variable.