ez.savem | R Documentation |
Writes .mat files for exporting data to be used with Matlab, more similar to matlab save() syntax
seems column in a data frame should be atomic if factor does not work well.
Writes .mat files to store R session data using the R.matlab package and
takes care that logicals and atomic vectors are saved properly: currently,
R.matlab does not write logicals and atomic vectors (not 1D arrays/ matrices)
in a way that they can be opened properly in Matlab (logicals will not be
stored and atomic vectors will be transposed in the Matlab session - but they
appear untransposed when read back from the .mat file into R using
R.matlab::readMat()). This function is a convenient wrapper for
R.matlab::writeMat() that stores logicals as 0 / 1 and that transposes atomic
vectors when saving the matfile.
ez.savem(file, vars)
ez.writem(file, vars)
file |
file name, a character string, with or without '.mat' |
vars |
character vector containing a comma separated listing of variables to be saved in the matfile. The variables have to exist in the environment where the function was called from. eg. 'var1,var2, var3' with or without (extra) space |
Christoph Schmidt <christoph.schmidt@med.uni-jena.de>
A <- matrix(c(2,3,4,2, 1,1,2,6, 8,3,9,7), 3, 4, byrow = TRUE)
b <- c(3, 5, 1, 9, 18, 2) # atomic vector 1x6
cc <- array(b, c(1, length(b))) # array vector 1x6
dd <- t(cc) # array vector 6x1
myChar <- c("from", "R", "to", "Matlab")
bool <- TRUE # logical
k <- FALSE
l <- FALSE
file <- "mytestmat"
vars <- "A, b, cc, dd, myChar, bool, k, l"
ez.savem(file, vars)
unlink(paste(file, ".mat", sep = ""))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.