On Sat, Jul 9, 2022 at 3:25 PM Sven Schreiber <svetosch(a)gmx.net> wrote:
Am 09.07.2022 um 12:22 schrieb Riccardo (Jack) Lucchetti:
> On Fri, 8 Jul 2022, Sven Schreiber wrote:
>
>> Hi all,
>>
>> I'm currently using the foreign block and specialized (user-defined) R
>> functions a bit more seriously. I'm noticing that the output from
>> print() calls inside the R functions does not seem to make it to the
>> outside. Consider the following minimal example:
>
> [...]
>
> An update on this. Allin and I spent some time trying to track the
> problem down, and we now think that this has something to do with the
> way we internally use the R shared library.
>
> The problem is, finding the documentation for that has proven to be a
> bit of a struggle. We'll see what we can do.
>
Thanks, Allin and Jack! So it doesn't seem to be a Windows-only issue.
If it's not fixable in the short term, I'd suggest to just create a bug
tracker ticket and postpone the fix, since it doesn't seem very urgent
to me.
I thought I'd replied to this before, but somehow my message didn't
get sent. Anyway, here's the story. When we're calling R in the usual
foreign-block setting we're sending R (binary or library, it doesn't
matter) some lines of R script. In that case it's easy to insert some
"sink()" statements to control where the output goes, so that gretl
can collect it. But if you call a previously defined R function via
gretl we're not sending any script, the transaction takes place
entirely via the libR API. There's no obvious way to control where any
R output goes, and in fact it goes automatically to stdout (evident if
you run Sven's test script in such a way that you can see stdout, e.g.
from the command line in a terminal window).
Jack and I tried searching the R documentation for a means of
controlling text output via the library API but we didn't find
anything yet. Some of the third-party libraries that gretl uses offer
a way of supplying a replacement for the standard C function printf()
-- e.g. libxml, libcurl -- but we can't find anything of that sort in
the libR API.
Allin