On Mon, 6 Jul 2009, Allin Cottrell wrote:
I've committed a few more changes to the gretl Rlib code. You
can
now (if you're set up right) call native R functions directly, as
in
<gretlscript>
scalar c = choose(10,4)
</gretlscript>
That is, "choose" is recognized as an R function and (thanks to
Christoph) is called via libR.
At present this works only if the function arguments and return
value are either scalars or matrices. That could be extended
somewhat if we find this valuable.
Wow! This is absolutely fantastic! However, this is big, very big. I have
the feeling that we need to think this over very carefully, for at least
two reasons:
(a) what happens in case of a name clash? This of course includes
user-defined functions. What's supposed to happen in a script in which the
"choose" string is already taken by a user-defined function? At present,
the non-R identifier takes precedence. Can this be source of trouble?
(b) are there portability problems? Some users may expect that in order
to run a gretl script, you need gretl, not R too. Otherwise, R becomes a
near-mandatory dependence; I'm not saying it's necessarily a bad thing,
but the implications are wide.
Perhaps we may wrap R function calls in an ad-hoc function, like
<gretlscript>
scalar c = R("choose(10,4)")
</gretlscript>
although this defeats the purpose a little bit. More thought needed.
Riccardo (Jack) Lucchetti
Dipartimento di Economia
Università Politecnica delle Marche
r.lucchetti(a)univpm.it
http://www.econ.univpm.it/lucchetti