[R] read.octave fails with data from Octave > 3.2.X

Helios de Rosario helios.derosario at ibv.upv.es
Tue Mar 27 19:05:44 CEST 2012


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.



More information about the R-help mailing list