Re: [R] writeMat error

2008-11-01 Thread Henrik Bengtsson
Hi,  a follow up on this as well: I've fixed the below bug in
writeMat().  R.matlab v1.2.4 is now available on CRAN.  Please update.

Henrik


On Wed, Oct 1, 2008 at 12:55 PM, Henrik Bengtsson [EMAIL PROTECTED] wrote:
 Hi.

 On Sat, Sep 27, 2008 at 5:17 AM, Steele, Dr Douglas [EMAIL PROTECTED] wrote:
 Hi

 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)
 library(R.matlab)
 writeMat('A.mat', A=A)

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

 It *is* created in the *current* directory.  If there are no errors,
 then it should be there.  Use can use getwd() to see which this is,
 e.g.

 library(R.matlab);
 A  -  c(1:10);
 dim(A) - c(2,5);
 writeMat(A.mat, A=A);
 print(getwd());

 [1] C:/Users/foo/braju.com.R/R.matlab

 print(list.files())
 [1] A.mat

 res - readMat(A.mat);
 str(res)
 List of 1
  $ A: int [1:2, 1:5] 1 2 3 4 5 6 7 8 9 10
  - attr(*, header)=List of 3
  ..$ description: chr MATLAB 5.0 MAT-file, Platform: windows,
 Software: R v2.7.2, Created on: Wed Oct 01 12:40:23 2008
 
  ..$ version: chr 5
  ..$ endian : chr little


 I tried both current version of R.matlab and older version because of bug
 https://stat.ethz.ch/pipermail/r-help/2008-September/173432.html

 Correct.  You should use install the old R.matlab v1.2.1, because
 v1.2.3 (as well as v1.2.2) contains a bug which is still to be fixed.


 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)
 print(data)
 unlink(fn)

 This is from example(writeMat).  It works this far, correct?  You
 should see 'data' being reported.  The unlink() command is there such
 that the example script cleans up after itself, i.e. it delete the
 temporary MAT file. Skip that last command if you want to grab the
 file.

 onWrite - function(x)
 writeBin(x$length, con=x$con, size=4, endian=big);
 writeMat(fn, A=A, B=B, onWrite=onWrite)

 Do *not* use these latter commands.  They are modifications of
 original example code that is only used to illustrate for advanced
 users how to send a MAT structure over a connection.  As indicated by
 the example code:

 ## Not run:
 # When writing to a stream connection the receiver needs to know in
 # beforehand how many bytes are available. This can be done by using
 # the 'onWrite' argument.
 onWrite - function(x)
   writeBin(x$length, con=x$con, size=4, endian=little);
 writeMat(con, A=A, B=B, onWrite=onWrite)
 ## End(Not run)

 they are within a Not run block, which in R means that they are not
 necessarily intended to be executed.  If you run the example code with
 example(writeMat) that code will not be executed.  You obviously
 cut'n'paste here, but didn't you see the above comments.  How you do
 view you help(), i.e. typically help(writeMat) will display those
 comments?  FYI, the first argument 'con' (supposed to indicate a
 connection) is on purpose non-existing and not the same as the 'fn'
 argument (pathname) in the preceeding code.


 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.

 Yes, but that is because you use that latter code.  Before writing the
 MAT structure, it writes the byte size of the structure to the file,
 which is not part of the MAT file format.  You don't want this.  This
 is only intended for sending MAT structure over a connection.


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

 Any advice would be very helpful

 Hope this helps

 Henrik


 Regards

 Douglas



 sessionInfo()
 R version 2.6.2 (2008-02-08)
 x86_64-pc-linux-gnu

 locale:
 LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C

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

 other attached packages:
 [1] R.matlab_1.2.1R.oo_1.4.6R.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.

 __
 R-help@r-project.org 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.



__
R-help@r-project.org 

Re: [R] writeMat error

2008-10-01 Thread Henrik Bengtsson
Hi.

On Sat, Sep 27, 2008 at 5:17 AM, Steele, Dr Douglas [EMAIL PROTECTED] wrote:
 Hi

 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)
 library(R.matlab)
 writeMat('A.mat', A=A)

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

It *is* created in the *current* directory.  If there are no errors,
then it should be there.  Use can use getwd() to see which this is,
e.g.

library(R.matlab);
A  -  c(1:10);
dim(A) - c(2,5);
writeMat(A.mat, A=A);
print(getwd());

[1] C:/Users/foo/braju.com.R/R.matlab

print(list.files())
[1] A.mat

res - readMat(A.mat);
 str(res)
List of 1
 $ A: int [1:2, 1:5] 1 2 3 4 5 6 7 8 9 10
 - attr(*, header)=List of 3
  ..$ description: chr MATLAB 5.0 MAT-file, Platform: windows,
Software: R v2.7.2, Created on: Wed Oct 01 12:40:23 2008
 
  ..$ version: chr 5
  ..$ endian : chr little


 I tried both current version of R.matlab and older version because of bug
 https://stat.ethz.ch/pipermail/r-help/2008-September/173432.html

Correct.  You should use install the old R.matlab v1.2.1, because
v1.2.3 (as well as v1.2.2) contains a bug which is still to be fixed.


 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)
 print(data)
 unlink(fn)

This is from example(writeMat).  It works this far, correct?  You
should see 'data' being reported.  The unlink() command is there such
that the example script cleans up after itself, i.e. it delete the
temporary MAT file. Skip that last command if you want to grab the
file.

 onWrite - function(x)
 writeBin(x$length, con=x$con, size=4, endian=big);
 writeMat(fn, A=A, B=B, onWrite=onWrite)

Do *not* use these latter commands.  They are modifications of
original example code that is only used to illustrate for advanced
users how to send a MAT structure over a connection.  As indicated by
the example code:

 ## Not run:
 # When writing to a stream connection the receiver needs to know in
 # beforehand how many bytes are available. This can be done by using
 # the 'onWrite' argument.
 onWrite - function(x)
   writeBin(x$length, con=x$con, size=4, endian=little);
 writeMat(con, A=A, B=B, onWrite=onWrite)
 ## End(Not run)

they are within a Not run block, which in R means that they are not
necessarily intended to be executed.  If you run the example code with
example(writeMat) that code will not be executed.  You obviously
cut'n'paste here, but didn't you see the above comments.  How you do
view you help(), i.e. typically help(writeMat) will display those
comments?  FYI, the first argument 'con' (supposed to indicate a
connection) is on purpose non-existing and not the same as the 'fn'
argument (pathname) in the preceeding code.


 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.

Yes, but that is because you use that latter code.  Before writing the
MAT structure, it writes the byte size of the structure to the file,
which is not part of the MAT file format.  You don't want this.  This
is only intended for sending MAT structure over a connection.


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

 Any advice would be very helpful

Hope this helps

Henrik


 Regards

 Douglas



 sessionInfo()
 R version 2.6.2 (2008-02-08)
 x86_64-pc-linux-gnu

 locale:
 LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C

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

 other attached packages:
 [1] R.matlab_1.2.1R.oo_1.4.6R.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.

 __
 R-help@r-project.org 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.


__
R-help@r-project.org 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.


[R] writeMat error

2008-09-27 Thread Steele, Dr Douglas
Hi

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)
library(R.matlab)
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
https://stat.ethz.ch/pipermail/r-help/2008-September/173432.html

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)
print(data)
unlink(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

Regards

Douglas



 sessionInfo()
R version 2.6.2 (2008-02-08)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_GB.UTF-8;LC_NUMERIC=C;LC_TIME=en_GB.UTF-8;LC_COLLATE=en_GB.UTF-8;LC_MONETARY=en_GB.UTF-8;LC_MESSAGES=en_GB.UTF-8;LC_PAPER=en_GB.UTF-8;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_GB.UTF-8;LC_IDENTIFICATION=C

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

other attached packages:
[1] R.matlab_1.2.1R.oo_1.4.6R.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.

__
R-help@r-project.org 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.


Re: [R] : writeMat

2008-09-10 Thread erola pairo
Hi,

that's the information about R and R.matlab:

*R version 2.6.2 (2008-02-08)
x86_64-pc-linux-gnu

locale:
C

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

other attached packages:
[1] R.matlab_1.2.3R.oo_1.4.5R.methodsS3_1.0.3 MASS_7.2-44

loaded via a namespace (and not attached):
[1] rcompgen_0.1-17
*
The matlab's version i'm using is* Matlab.7.6.0.  *and the error matlab
gives me is:

*??? Error using == load
Unable to read MAT-file /home/erola/Dades/Saccharomyces cerevisiae/A.mat

File may be corrupt.*

I tried to put in matlab preferences -v6 saving, but it doesn't work.

I have the same  Matlab's version that a month ago, I thought that it was
all the same but I have a problem with my computer and I have to reinstall
all again, and somethimg is been changed, but I don't know what.

Thank you.



On Tue, Sep 9, 2008 at 8:58 PM, Henrik Bengtsson [EMAIL PROTECTED]wrote:

 Hi,

 On Tue, Sep 9, 2008 at 9:53 AM, erola pairo [EMAIL PROTECTED] wrote:
  I write a .mat file using the writeMat() command, but when i try to load
 it
  in Matlab it says that  file may be corrupt. I did it a month ago and it
  worked. It exists any option that I can change for making the file
 readable
  to Matlab?
 
  A  -  c(1:10)
  dim(A) - c(2,5)
  library(R.matlab)
  writeMat('A.mat', A=A)
 
  And what matlab say is:
  file may be corrupt

 you need to provide much more information that this.  Please see the
 posting guides for the list (see footer), and provide sessionInfo() so
 we know what version of R and R.matlab you are using.  What version of
 Matlab are you using?  If it worked a month ago, what have you changed
 since then?

 Cheers

 Henrik
 (author of R.matlab)

 
  Regards
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org 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.
 


[[alternative HTML version deleted]]

__
R-help@r-project.org 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.


Re: [R] : writeMat

2008-09-10 Thread Henrik Bengtsson
Hi,

I've managed to reproduce the error with R.matlab v1.2.2 and Matlab
v7.4.0.287 (R2007a).

There seems to be a bug introduced in R.matlab v1.2.2 (2008-07-12). In
this version we tried to optimize the speed of writeMat(), and
something failed (although all tests show the generated files loads
fine with readMat() in R).  You have probably updated R.matlab to this
version, which is why it worked before.

Until I identify and fix the bug, you can roll back to an earlier
version that I have verified works.  Start a fresh R session and
install R.matlab v.1.2.1 as follows:

source(http://www.braju.com/R/hbLite.R;);
installPackages(http://www.braju.com/R/repos/R.matlab_1.2.1.tar.gz;);

(Windows users should replace *.tar.gz with *.zip).

Let me know if this helps and thanks for reporting the bug

Henrik

PS. It's time to update your R installation. DS.


On Wed, Sep 10, 2008 at 9:47 AM, erola pairo [EMAIL PROTECTED] wrote:
 Hi,

 that's the information about R and R.matlab:

 R version 2.6.2 (2008-02-08)
 x86_64-pc-linux-gnu

 locale:
 C

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

 other attached packages:
 [1] R.matlab_1.2.3R.oo_1.4.5R.methodsS3_1.0.3 MASS_7.2-44

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

 The matlab's version i'm using is Matlab.7.6.0.  and the error matlab gives
 me is:

 ??? Error using == load
 Unable to read MAT-file /home/erola/Dades/Saccharomyces cerevisiae/A.mat

 File may be corrupt.

 I tried to put in matlab preferences -v6 saving, but it doesn't work.

 I have the same  Matlab's version that a month ago, I thought that it was
 all the same but I have a problem with my computer and I have to reinstall
 all again, and somethimg is been changed, but I don't know what.

 Thank you.



 On Tue, Sep 9, 2008 at 8:58 PM, Henrik Bengtsson [EMAIL PROTECTED]
 wrote:

 Hi,

 On Tue, Sep 9, 2008 at 9:53 AM, erola pairo [EMAIL PROTECTED] wrote:
  I write a .mat file using the writeMat() command, but when i try to load
  it
  in Matlab it says that  file may be corrupt. I did it a month ago and it
  worked. It exists any option that I can change for making the file
  readable
  to Matlab?
 
  A  -  c(1:10)
  dim(A) - c(2,5)
  library(R.matlab)
  writeMat('A.mat', A=A)
 
  And what matlab say is:
  file may be corrupt

 you need to provide much more information that this.  Please see the
 posting guides for the list (see footer), and provide sessionInfo() so
 we know what version of R and R.matlab you are using.  What version of
 Matlab are you using?  If it worked a month ago, what have you changed
 since then?

 Cheers

 Henrik
 (author of R.matlab)

 
  Regards
 
 [[alternative HTML version deleted]]
 
  __
  R-help@r-project.org 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.
 



__
R-help@r-project.org 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.


[R] : writeMat

2008-09-09 Thread erola pairo
I write a .mat file using the writeMat() command, but when i try to load it
in Matlab it says that  file may be corrupt. I did it a month ago and it
worked. It exists any option that I can change for making the file readable
to Matlab?

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

And what matlab say is:
file may be corrupt

Regards

[[alternative HTML version deleted]]

__
R-help@r-project.org 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.