read.octave fails with data from Octave > 3.2.X

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

read.octave fails with data from Octave > 3.2.X

Helios de Rosario
Hi,

I'm afraid that the function read.octave from package "foreign" has
some problems with the ASCII data format exported by new versions of
Octave (later than 3.2.X). It fails even for a simple case as:

[Octave code:]
octave:1> x=1;
octave:2> save -ascii testdata.mat x

[Now in R:]
> octavedata <- read.octave('testdata.mat')
Mensajes de aviso perdidos
In read_octave_unknown(con, type) : cannot handle unknown type ''

In this simple case I guess that the problem is that new versions
Octave append two blank lines after each variable, and this confuses the
current implementation of read.octave()

The problem is worse if the saved variables include other types as
structs, or strings. The new syntax of the MAT files is not recognized
by read.octave().

Of course, it's always difficult to keep this kind of functions working
when the external program changes its specification for saving
variables, but if would be nice if the maintainers of "foreign" could at
least solve the issue of blank lines. That way, it would still be
possible to import simple data types as scalars and matrices.

Otherwise, I suppose that a workaround is saving the data in binary
(matlab) format, then load it with Octave 3.2.X, and save it in text
format from that version.

> sessionInfo()
R version 2.14.2 (2012-02-29)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=Spanish_Spain.1252  LC_CTYPE=Spanish_Spain.1252
[3] LC_MONETARY=Spanish_Spain.1252 LC_NUMERIC=C
[5] LC_TIME=Spanish_Spain.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] foreign_0.8-49




--
Helios de Rosario Martínez
 
 Researcher


INSTITUTO DE BIOMECÁNICA DE VALENCIA
Universidad Politécnica de Valencia • Edificio 9C
Camino de Vera s/n • 46022 VALENCIA (ESPAÑA)
Tel. +34 96 387 91 60 • Fax +34 96 387 91 69
www.ibv.org

  Antes de imprimir este e-mail piense bien si es necesario hacerlo.
En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección
de Datos de Carácter Personal, le informamos de que el presente mensaje
contiene información confidencial, siendo para uso exclusivo del
destinatario arriba indicado. En caso de no ser usted el destinatario
del mismo le informamos que su recepción no le autoriza a su divulgación
o reproducción por cualquier medio, debiendo destruirlo de inmediato,
rogándole lo notifique al remitente.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: read.octave fails with data from Octave > 3.2.X

Helios de Rosario
I wrote in my previous message the following Octave code:

[Octave code:]
octave:1> x=1;
octave:2> save -ascii testdata.mat x

Forget the "-ascii". It should be "-text" or nothing ("-text" is the
default).

By the way, read.octave() does not really "fail" (it does return a
value), but the result is somewhat corrupted: it contains the exported
"x" variable, plus other empty elements corresponding to the blank
lines, I think.

Helios
INSTITUTO DE BIOMECÁNICA DE VALENCIA
Universidad Politécnica de Valencia • Edificio 9C
Camino de Vera s/n • 46022 VALENCIA (ESPAÑA)
Tel. +34 96 387 91 60 • Fax +34 96 387 91 69
www.ibv.org

  Antes de imprimir este e-mail piense bien si es necesario hacerlo.
En cumplimiento de la Ley Orgánica 15/1999 reguladora de la Protección
de Datos de Carácter Personal, le informamos de que el presente mensaje
contiene información confidencial, siendo para uso exclusivo del
destinatario arriba indicado. En caso de no ser usted el destinatario
del mismo le informamos que su recepción no le autoriza a su divulgación
o reproducción por cualquier medio, debiendo destruirlo de inmediato,
rogándole lo notifique al remitente.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.