Skip to content

exporting multidimensional matrix from R

3 messages · Gopikrishna Deshpande, David Winsemius

#
On Jan 28, 2010, at 10:42 AM, Gopikrishna Deshpande wrote:

            
No, you don't. Matrices are only 2 dimensional in R. You may have an  
"array", however.
install.packages(pkgs="R.matlab", dependencies=TRUE)
library(R.matlab)
?writeMat
filename <- "~/test.mat"
writeMat(filename, arr=arr)

 > readMat(filename)
$arr
, , 1

      [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9

, , 2

      [,1] [,2] [,3]
[1,]   10   13   16
[2,]   11   14   17
[3,]   12   15   18

, , 3

      [,1] [,2] [,3]
[1,]   19   22   25
[2,]   20   23   26
[3,]   21   24   27


attr(,"header")
attr(,"header")$description
[1] "MATLAB 5.0 MAT-file, Platform: unix, Software: R v2.10.1, Created  
on: Thu Jan 28 12:08:25 2010                              "

attr(,"header")$version
[1] "5"

attr(,"header")$endian
[1] "little"
David Winsemius, MD
Heritage Laboratories
West Hartford, CT