Sharing large datasets between Matlab and R

后端 未结 2 1159
悲哀的现实
悲哀的现实 2020-12-28 18:52

I need a relatively efficient way to share data between Matlab and R.

I have checked SaveR and MATLAB R-link, but SaveR formats Matlab\'s binary dat

相关标签:
2条回答
  • 2020-12-28 19:15

    Matlab use HDF5 natively in last versions ("save" and "load"). There is a package for R. Then HDF5 might be a good solution.

    0 讨论(0)
  • 2020-12-28 19:31

    Couple of ideas, and with the caveat that I know more about the R side of things:

    • Tthe R.matlab package on CRAN can help: This package provides methods to read and write MAT files. It also makes it possible to communicate (evaluate code, send and retrieve objects etc.) with Matlab v6 or higher running locally or on a remote host

    • HDF5, as you suggested, is a possibility but I heard that the R support in CRAN package hdf5 is somewhat basic

    • NetCDF may be an alternative; CRAN has packages RNetCDF, ncdf and ncdf4

    • Use a database, especially a light and file-based one like SQLite or H4 both of which have R support

    • Use a common serialization / de-serialization format; R has support for Google Protocol Buffers via RProtoBuf and Google points to protobuf-matlab for Matlab

    • Write your own! Especially when you only need something basic like large rectangular matrices then nothing will beat a direct binary write; I did this once years ago for Octave (which is close to Matlab). You can extend Matab via mex files; R has its API and helpers like Rcpp. The larger your data sets, the more attractive this may look as you save the conversions.

    0 讨论(0)
提交回复
热议问题