Import serialized R® data files directly into MATLAB® without running R. Convert R objects to MATLAB arrays, strings, categoricals, datetimes, tables, and dictionaries, with metadata that records missing values and R attributes.
Requires MATLAB R2023a or later. No R, Java®, or Git™ installation is required at runtime.
For MATLAB R2026b or later, install directly from MATLAB with:
mpminstall rdatareaderFor all supported releases, you can also install MATLAB Reader for R Data Files through Add-On Explorer or find it on File Exchange.
To install manually, download the latest rDataReader.mltbx. In MATLAB R2026b or later, install the downloaded file with:
mpminstall("path/to/rDataReader.mltbx")For earlier supported releases, open the downloaded .mltbx file in MATLAB to
install it.
To use a source checkout, clone the repository and add tbx/rdatareader to
the path.
This example downloads and imports public economic data from the R package AER. The repository and toolbox do not include these data or saved example output.
url = "https://raw.githubusercontent.com/cran/AER/master/data/OECDGrowth.rda";
options = weboptions(Timeout=30, ContentReader=@rdata2table);
T = webread(url, options);
head(T)To read local files or inspect their metadata:
value = readrds("data.rds");
workspace = readrdata("workspace.RData");
info = rdatainfo("data.rds");See Getting Started and the function reference: readrds, readrdata, rdata2table, and rdatainfo.
| R data | MATLAB representation |
|---|---|
| Logical, integer, real, complex, and raw vectors | Logical, double, complex, and uint8 arrays; integers optionally stored as int32 |
| Character vectors | String arrays; optional cell arrays of character vectors |
| Matrices and arrays | Arrays that preserve the R dimensions |
| Factors and ordered factors | Categorical arrays that preserve levels and ordering |
| Date, POSIXct, and difftime values | datetime and duration arrays |
| Data frames and tibble-like objects | Tables; optional timetables through rdata2table |
| Named lists and workspaces | Dictionaries that preserve the original R names |
| Unnamed lists | Cell arrays |
- Reads
.rds,.rda, and.RDatafiles using binary XDR or native binary serialization (versions 2 and 3). Supports uncompressed and gzip-compressed files. - ASCII serialization and bzip2, xz, and zstd compression are not supported.
- Duplicate names are rejected. Table columns with empty, missing,
or reserved names (
:,Properties,Row,Variables) are rejected. Other names, including spaces and punctuation, are preserved unchanged. - R missing logical values become
false; use metadata to distinguish them. WithTextType="cellstr", missing and empty strings both become empty character vectors. WithIntegerType="int32", missing integers retain the R NA sentinel. See missing-value details. - Functions, environments, formulas, promises, bytecode, external pointers,
and unsupported class-specific behavior are not reconstructed or executed.
PreserveUnsupported="opaque"provides diagnostic placeholders;"raw"exposes an unstable internal representation for diagnostics only. - Fitted model objects do not become executable prediction models. See model adapter scope.
- Files are processed in memory. Large compressed files can require substantially more memory than their on-disk size.
See compatibility and validation, troubleshooting, and release notes.
The development project and release build require MATLAB R2026b. Generating
test fixtures and running oracle tests also require Rscript. To run the
default test suite, start from the repository root:
openProject("matlab.toml")
buildtool testRun buildtool testall for the complete suite. CI saves test and coverage
reports as workflow artifacts. See DEVELOPMENT.md for release
builds and testing on the minimum runtime release.
External pull requests are currently not accepted. Report reproducible bugs through GitHub® issues. For security vulnerabilities, follow SECURITY.md.