R-Forge Logo

Welcome to rErlang - R/Erlang Interface project!

This project provides a library which is a bi-directional interface allowing calling R functions from Erlang code and accessing Erlang functions from R sessions.

The package is now publicly accessible from the SVN repository.

What's rErlang?

To communicate with R, Erlang ports (Ports), ei (Erlang Interface) library and OTP standard behaviors are used in Erlang side. Ports provides a byte-oriented interface to an external program. ei helps conversion of data between C and Erlang formats. And also we want to ensure that rErlang is robust in the event that the external problems or does not respond in a timely manner. The use of standard OTP enables us to do so with minimal effort.

What's new?

2009/08/05Project is registered

Features of rErlang

Coming Soon !

This project is just getting started. Please join us!

Binding rules of data types between R and Erlang

Coming Soon !

Tutorial

Erlang -> R

usr@home: erl
Erlang (BEAM) emulator version 5.6.3 [source] [smp:2] [async-threads:0] [kernel-poll:false]

Eshell V5.6.3  (abort with ^G)
1> eri:start().
<0.33.0>
2> eri:connect().
{ok,0}
3> eri:eval("1:9").
{ok,'INTSXP',[1,2,3,4,5,6,7,8,9]}
4> {ok, Type, Result} = eri:eval("rnorm(10)").
5> Type.  
'REALSXP'
6> Result.
[-0.1917861903879111,1.0077673823951807,0.05707066688405165,
 -1.7174303197492615,0.6188926676115155,0.25904560550869155,
 0.5981845165498236,-0.4449771878757933,1.0737026013065656,
 0.22614169517088667]

R -> Erlang


user@home:~/rerlang/trunk/bin$ R
R version 2.9.2 (2009-08-24)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

REvolution R enhancements not installed.  For improved
performance and other extensions: apt-get install revolution-r

> source("rErlang.R")
> connect()
[1] 0
> eval("1+1")
{badrpc,{'EXIT',{{badmatch,{error,{1,erl_parse,["syntax error before: ",[]]}}},[{rErlang,eval,1},{rpc,'-handle_call/3-fun-0-',5}]}}}[1] "ok"
> eval("1+1.")
2[1] "ok"
> eval("eri:start().")
[1] "ok"
> eval("eri:connect()")
{badrpc,{'EXIT',{{badmatch,{error,{1,erl_parse,["syntax error before: ",[]]}}},[{rErlang,eval,1},{rpc,'-handle_call/3-fun-0-',5}]}}}[1] "ok"
> eval("eri:connect().")
{ok,0}[1] "ok"
> eval("eri:eval(\"1:9\").")
{ok,'INTSXP',[1,2,3,4,5,6,7,8,9]}[1] "ok"
> eval("eri:eval(\"1:9\").")
 以下にエラー eval("eri:eval(\"1:9\").") : ignoring SIGPIPE signal
> 
> q()
Save workspace image? [y/n/c]: n
keisuke@avalon:~/rerlang/trunk/bin$ R
R version 2.9.2 (2009-08-24)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

REvolution R enhancements not installed.  For improved
performance and other extensions: apt-get install revolution-r