Helios de Rosario
2012-Mar-27 17:05 UTC
[R] read.octave fails with data from Octave > 3.2.X
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.
Helios de Rosario
2012-Mar-27 19:50 UTC
[R] read.octave fails with data from Octave > 3.2.X
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.