function void mytrack(list x)
text3 = "sin(pi/4)"
foreign language=R --send-data=x
setClass("track", representation(x="numeric",
y="numeric"));
myTrack <- new("track", x = -4:4, y = exp(-4:4));
myTrack@x
txt <- @text3;
print(txt)
head(gretldata)
end foreign
end function
nulldata 10
set seed 13
x = normal()
y = normal()
list li = x y
mytrack(li)
Work both S4-slot and a text from gretl
Oleh
10 лютого 2017, 09:28:41, від "Sven Schreiber" <svetosch(a)gmx.net>:
Am 10.02.2017 um 02:16 schrieb Allin Cottrell:
> On Thu, 9 Feb 2017, oleg_komashko(a)ukr.net wrote:
>
>> Gretl have a finite number of foreign interfaces May be, a decent
>> solution is in making the use of '@' foreign language-specific (or,
>> python-specific) With R it is a luxurous feature: it makes transfer of
>> non-series data very convinient I'd prefer for changes to be specific
>> and not to remove this possibility from foreign R.
>
> OK, we won't make any precipitate changes, and it may make sense to
> treat different "foreign" languages differently. (We already handle
> python specially on account of its idiosyncratic treatment of white
> space as syntactically significant.)
>
> But could you elaborate on how string substitution is convenient in
> relation to R? (Maybe we could recommend an alternative approach, or
> maybe not.)
I'm leaning more and more towards the position that unconditional
substitution would either have to be banned in 'foreign' or should be
user configurable (as in "foreign language=R --strsubst=on").
Because I have verified that the "@" character also has its own meaning
in R:
https://stat.ethz.ch/R-manual/R-devel/library/methods/html/slot.html
So if a script author requests string substitution for a foreign block,
it would be her/his responsibility to avoid such ambiguities. It could
also be useful to have this choice on a block-per-block basis and not
for the entire script (as the above suggestion would ensure).
Don't know how much effort the implementation would imply.
thanks,
sven
_______________________________________________
Gretl-devel mailing list
Gretl-devel(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-devel