[R] writeMat error

Steele, Dr Douglas d.steele at abdn.ac.uk
Sat Sep 27 14:17:38 CEST 2008


I am using Ubuntu 8.04 64 bit, R as below, Matlab 7.6.0.  I would like to transfer mat files back and forward between R and Matlab.  Whilst I have used Matlab for years its been a long time since I have used R (hence question may be a bit simple)

Running code

A  <-  c(1:10)
dim(A) <- c(2,5)
writeMat('A.mat', A=A)

Does not appear to generate any mat file either in local directory or in /tmp/R*

I tried both current version of R.matlab and older version because of bug

A <- matrix(1:27, ncol=3)
B <- as.matrix(1:10)
fn <- paste(tempfile(), ".mat", sep="")
writeMat(fn, A=A, B=B)
data <- readMat(fn)
onWrite <- function(x)
writeBin(x$length, con=x$con, size=4, endian="big");
writeMat(fn, A=A, B=B, onWrite=onWrite)

Does generate a file in /tmp/Rtmpjhfjxw
-rw-r--r--  1 dst dst  396 2008-09-27 12:46 file643c9869.mat

When I try to read it into Matlab I get

??? Error using ==> load
Unable to read MAT-file /tmp/Rtmpjhfjxw/file643c9869.mat

File may be corrupt.

(This is same error message as above link and occurs with old and current version of R.matlab)

Any advice would be very helpful



> sessionInfo()
R version 2.6.2 (2008-02-08)


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

other attached packages:
[1] R.matlab_1.2.1    R.oo_1.4.6        R.methodsS3_1.0.3

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17

The University of Aberdeen is a charity registered in Scotland, No SC013683.

More information about the R-help mailing list