On 10/28/2010 03:16 PM, Thomas Levine wrote:> Is there a particular reason you can't use csv?
(Not sure whether I'm meant - as I also suggested csv to Santosh)
But:
- It used to work, so there may be code existing that is broken now (e.g. I do
have such code, but at least for the moment it doesn't matter). Thus the
information may very well be of interest for the maintainer.
- csv is fine for a matrix (or a vector) or a data.frame. How about arrays,
lists, more than one variable?
I think the default file format changed to v7.3 (though I'm not sure whether
that is just for large variables).
Unfortunately -v switch of load (that used e.g. to allow reading of V4 files) is
gone, and I can't see anything to specify the .mat file format version.
The curious thing is that readMat does accept the file produced by Matlab 2008b.
If it is a matter of writeMat writing an old file format, I'd have expected
that
rather load should still be able to read the writeMat generated file than
readMat being able to read Matlab's .mat file.
my 2 ct
Claudia
>
> write.csv() in R
>
> It seems that you can read csv in Matlab with this
> http://www.mathworks.com/help/techdoc/ref/importdata.html
>
> Tom
>
> 2010/10/28 Claudia Beleites<cbeleites at units.it>:
>>> I am looking for ways to use R and Matlab. Doing the data
transformations
>>> in
>>> R and using the data in Matlab to analyze with some pre-defined
scripts.
>>> Any good ways to transfer the data into matlab in its most recent
version?
>>> I tried using R.matlab but the writeMat output is not readable by
Matlab.
>>
>> It used to work, but I didn't need it for quite a while (a year or
so ago,
>> and with Matlab either 2007 or 2008a).
>>
>> I just tried, and neither does it work for me.
>> You should notify the maintainer of R.matlab and include an example
(code
>> and data, e.g. with dput).
>>
>> I noticed that library (R.matlab) does not load the Rcompression
package,
>> but also after library (Rcompression), the resulting file was not read
by
>> Matlab.
>>
>> I tried loading a saved data.frame in Matlab 2008b on an Win XP
computer: it
>> doesn't find any variables inside the .mat file (and whos -file
...) doesn't
>> show a variable.
>>
>> The other way round with a stupid little vector it worked.
>>
>> An R session (with only the 2nd try, after library (Rcompression)) is
>> attached below.
>>
>>
>>> I just need to output a data.frame and read it as is into matlab
where I
>>> can
>>> do any needed transformations on the variables.
>>
>> If you need to transfer the data right NOW, there's always csv.
>>
>> Claudia
>>
>> ********************
>>
>>> library (hyperSpec)
>> Loading required package: lattice
>> Package hyperSpec, version 0.95
>>
>> To get started, try
>> vignette ("introduction", package = "hyperSpec")
>> package?hyperSpec
>> vignette (package = "hyperSpec")
>>
>> If you use this package please cite it appropriately.
>> citation("hyperSpec")
>> will give you the correct reference.
>>
>> The project is hosted on
http://r-forge.r-project.org/projects/hyperspec/
>>
>>> sessionInfo ()
>> R version 2.12.0 (2010-10-15)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>> locale:
>> [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
LC_TIME=en_US.utf8
>> [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C
>> LC_MESSAGES=en_US.utf8
>> [7] LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C
>> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.utf8
LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>> other attached packages:
>> [1] hyperSpec_0.95 lattice_0.19-13 R.matlab_1.3.3 R.oo_1.7.4
>> R.methodsS3_1.2.1
>>
>> loaded via a namespace (and not attached):
>> [1] grid_2.12.0
>>> library (Rcompression)
>>> x = flu[[]]
>>> writeMat ("flu.mat", flu)
>> Error in dim(x)<- length(x) : invalid first argument
>>> writeMat ("flu.mat", x)
>>> sessionInfo ()
>> R version 2.12.0 (2010-10-15)
>> Platform: x86_64-pc-linux-gnu (64-bit)
>>
>> locale:
>> [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C
LC_TIME=en_US.utf8
>> [4] LC_COLLATE=en_US.utf8 LC_MONETARY=C
>> LC_MESSAGES=en_US.utf8
>> [7] LC_PAPER=en_US.utf8 LC_NAME=C LC_ADDRESS=C
>> [10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.utf8
LC_IDENTIFICATION=C
>>
>> attached base packages:
>> [1] stats graphics grDevices utils datasets methods base
>>
>> other attached packages:
>> [1] Rcompression_0.8-0 hyperSpec_0.95 lattice_0.19-13
R.matlab_1.3.3
>> R.oo_1.7.4
>> [6] R.methodsS3_1.2.1
>>
>> loaded via a namespace (and not attached):
>> [1] grid_2.12.0
>>
>>
>>
>> --
>> Claudia Beleites
>> Dipartimento dei Materiali e delle Risorse Naturali
>> Universit? degli Studi di Trieste
>> Via Alfonso Valerio 6/a
>> I-34127 Trieste
>>
>> phone: +39 0 40 5 58-37 68
>> email: cbeleites at units.it
>>
>> ______________________________________________
>> R-help at 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.
>>
--
Claudia Beleites
Dipartimento dei Materiali e delle Risorse Naturali
Universit? degli Studi di Trieste
Via Alfonso Valerio 6/a
I-34127 Trieste
phone: +39 0 40 5 58-37 68
email: cbeleites at units.it