read_mat | R Documentation |
A compatible reader that can read both 'Matlab' files prior and after version 6.0
read_mat(file, ram = TRUE)
read_mat2(file, ram = TRUE)
file |
path to a 'Matlab' file |
ram |
whether to load data into memory. Only available when the file is in 'HDF5' format. Default is false and will load arrays, if set to true, then lazy-load data. This is useful when array is very large. |
readMat
can only read 'Matlab' files
prior to version 6. After version 6, 'Matlab' uses 'HDF5' format
to store its data, and read_mat
can handle both cases.
The performance of read_mat
can be limited when
the file is too big or has many datasets as it reads all the
data contained in 'Matlab' file into memory.
A list of All the data stored in the file
readMat
, load_h5
# Matlab .mat <= v7.3
x <- matrix(1:16, 4)
f <- tempfile()
R.matlab::writeMat(con = f, x = x)
read_mat(f)
# Matlab .mat >= v7.3, using hdf5
# Make sure you have installed hdf5r
if( dipsaus::package_installed('hdf5r') ){
f <- tempfile()
save_h5(x, file = f, name = 'x')
read_mat(f)
# For v7.3, you don't have to load all data into RAM
dat <- read_mat(f, ram = FALSE)
dat
dat$x[]
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.