Thank you for your answers and apologies for the delayed response, I had to contact our
admin, because of a safety feature under Windows, that required admin rights for the first
launch of Gretl 2016e git.
I have tried to run Allin's first example, but still got an error message
("Datenfehler" <-> "Data error")
I have provided the script's printout below (in German only)
I have no clue, why the script works on your systems but not on mine.
Nonetheless, thank you all.
Best,
Jan
gretl-Version 2016e-git
Aktuelle Sitzung: 2017-01-03 15:11 #current session
? matrix M = mnormal(3, 2)
? M[1,2] = 0/0 # introduce a NaN value
Warnung: erzeugte nichtendliche Werte #Warning message that nan's were created
? print M
M (3 x 2)
1,4152 nan
0,47459 0,078130
0,34524 0,32018
? mwrite(M, "M.mat", 1)
? foreign language=R
? M1 <- gretl.loadmat("M.mat")
? gretl.export(M1, "M2")
? end foreign
wrote matrix C:/Users/JTille/AppData/Roaming/gretl/M2.mat
? matrix M2 = mread("M2.mat", 1)
Datenfehler # Error message
Fehler bei Skriptausführung: Stopp #message that the script stopped
matrix M2 = mread("M2.mat", 1)
-----Ursprüngliche Nachricht-----
Von: Plus.line MailSystem [mailto:cyrus@mailer.plusline.de] Im Auftrag von Allin Cottrell
Gesendet: Dienstag, 3. Januar 2017 01:45
An: r.lucchetti(a)univpm.it; Gretl list <gretl-users(a)lists.wfu.edu>
Betreff: Re: [Gretl-users] Problems when trying to interac with R
On Tue, 3 Jan 2017, Riccardo (Jack) Lucchetti wrote:
On Mon, 2 Jan 2017, Sven Schreiber wrote:
> Am 02.01.2017 um 18:13 schrieb Jan Tille:
>
>> matrix r_test2={} set skip_missing off matrix
>> r_test2={NA,0.31643,-0.11822,2.9720 ; NA, 0.96456,-0.58746,1.4570 ;
>> NA, 0.79388,0.54611,-1.0222} print r_test2
>
> OK, I see, it's the missings.
>
> More precisely: The matrix saved by R (via gretl.export) represents
> the missings as "NaN", while gretl seems to prefer "nan"
(lowercase).
>
> (also @Allin:) I manually changed all "NaN" to "nan" in the saved
> file and then gretl's mread() accepts it.
>
> Jan, as a workaround for your case until this is fixed, could you
> somehow restrict your data to have no missings already in gretl,
> before you call R, then it should work.
Jan's example 2 runs fine on current git.
IIRC, Allin committed a few changes on the handling of NAs in mat
files shortly before Christmas.
Could you try the snapshot version?
I agree with Jack's diagnosis here: I think this problem is (mostly) already fixed in
git. The following script works OK:
<hansl>
matrix M = mnormal(3, 2)
M[1,2] = 0/0 # introduce a NaN value
print M
mwrite(M, "M.mat", 1)
foreign language=R
M1 <- gretl.loadmat("M.mat")
gretl.export(M1, "M2")
end foreign
matrix M2 = mread("M2.mat", 1)
print M2
</hansl>
The retrieved matrix M2 is the same as the original M. In addition, this modified version
also works alright:
<hansl>
open data4-1
matrix M = mnormal(3, 2)
M[1,2] = 0/0 # introduce a NaN value
print M
mwrite(M, "M.mat", 1)
foreign language=R --send-data
M1 <- gretl.loadmat("M.mat")
gretl.export(M1, "M2")
end foreign
matrix M2 = mread("M2.mat", 1)
print M2
</hansl>
Now, if you take the second version and delete the line "open data4-1" (so that
there's no dataset to send in response to the --send-data option), then executing the
script produces:
<output>
...
? end foreign
write_data_for_R: failed with err = 15
</output>
This is admittedly too cryptic, but it's a "correct" error message in that
the function write_data_for_R() has failed, for the reason that there's nothing to
write.
Allin
_______________________________________________
Gretl-users mailing list
Gretl-users(a)lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users