On Wed, 24 Jan 2018, Riccardo (Jack) Lucchetti wrote:
I tried to reproduce [Artur's] problem here on Debian (and I
spent
quite a long time wondering what was wrong with your example before
I realised I hadn't the "moments" R library installed. Oh well).
Footnote on Rlib use from gretl. How do you call an R function from
within gretl if that function requires a library that's not loaded by
default?
I showed one way in
http://lists.wfu.edu/pipermail/gretl-devel/2018-January/008399.html
namely, use a "foreign" block to define an R wrapper function which
first loads the library then executes the call(s), as in
<hansl>
foreign language=R --quiet
skewness_R <- function(x) {
library(moments)
skewness(x)
}
end foreign
scalar s = R.skewness_R(x)
</hansl>
However, there's an alternative, illustrated below:
<hansl>
foreign language=R --quiet
library(moments)
end foreign
scalar s = R.skewness(x)
</hansl>
That is, libR retains state such that the moments library will be
available when R.skewness is called.
Allin