[Gretl-devel] Re: Rlib daily update!

Allin Cottrell cottrell at wfu.edu
Sat Jul 11 13:53:24 EDT 2009


On Thu, 9 Jul 2009, Allin Cottrell wrote:

> Then there's the last point: look-up of R functions.  For the
> present I've left this as I last described it.  You have to "set
> R_functions" on to get this.  This depends on compiled-in Rlib
> support, but it does not depend on setting "R_lib" on. And you
> need to prepend "R_" to the function names to have them found.

Update: we're now following Sven's suggestion and using "R.", not
"R_", for the R function namespace.

Unless I'm missing something, there shouldn't be any collisions
with native gretl things.  You could save a model named "R"
and refer to it in the context of a "genr" expression but:

* to be a valid gretl construct, the next character after "R."
would have to be '$', to get an accessor such as "R.$coeff", and

* '$' can't be the first character of an R function name, can
it?

So I think we're alright.

New illustration:

open data4-1
set R_functions on
foreign language=R
  ols <- function(y,x) {
    m <- lm(y~x + 1)
    b <- as.matrix(coefficients(m))
    invisible(b)
  }
end foreign
set messages off
matrix rb = R.ols(price, sqft)
rb

Allin.


More information about the Gretl-devel mailing list