Has anyone developed any kind of bindings with R-project to call R
from OCaml programs ? If so, is it available somewhere ?
Thanks,
Maxence Guesdon
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
On Fri, Mar 14, 2008 at 7:32 AM, Maxence Guesdon <maxence...@inria.fr>
wrote:
2008/3/15 Ashish Agarwal <agarw...@gmail.com>:
On Sat, Mar 15, 2008 at 12:08 PM, Francois Rouaix <francoi...@gmail.com>
wrote:
> And why do you need bindings instead of simply feeding generated source code
> to the R toplevel?Low-level bindings are mostly useful if the calls go both
> ways or if the parsing costs represent a high overhead.
Because
- Printf-ing the code is kind of heavy and error-prone,
- parsing the computed values is some work to handle correctly,
- the compiler can't tell me if I did something wrong so I get all the
errors at execution time.
Maxence
> Because
> - Printf-ing the code is kind of heavy and error-prone,
> - parsing the computed values is some work to handle correctly,
> - the compiler can't tell me if I did something wrong so I get all
> the errors at execution time.
This need not be the case if you apply language embedding/meta-
programmation techniques (see for example [1]). You can even mask R
computations behind plain caml functional types.
I have an unpolished toy example that does this to program arithmetic
functions on regular ocaml types but that use scsh to actually compute
the result (no camlp4 or unsafe features required), I can forward it
to you if you are interested.
Here's an example of a polymorphic cube function, when you invoke
cubei or cubef the result will actually be computed by scsh. The
drawback is that you need to "write" the type your functions by hand
(cf argi argf reti retf).
open Mini
open Override
open Program
let cube_s = fun x -> x * x * x
let cubei_p = compile (argi (reti cube_s))
let cubef_p = compile (argf (retf cube_s))
let cubei : int -> int = as_fun cubei_p
let cubef : float -> float = as_fun cubef_p
However as Ashish pointed out the biggest problem are the data sets,
but it may be that you can keep them in R only with suitable types to
represent them in ocaml.
Best,
Daniel
[1]
article{967844,
author = {Conal Elliott and Sigbj\&\#248;rn Finne and Oege De Moor},
title = {Compiling embedded languages},
journal = {J. Funct. Program.},
volume = {13},
number = {3},
year = {2003},
issn = {0956-7968},
pages = {455--481},
doi = {http://dx.doi.org/10.1017/S0956796802004574},
publisher = {Cambridge University Press},
address = {New York, NY, USA},