MATLAB Answers

Can MATLAB read 'R' data files (*.Rda) directly?

178 views (last 30 days)
Richard on 16 Sep 2014
Commented: Andrew on 22 Sep 2020
If so, what is the appropriate function?


Sign in to comment.

Answers (1)

Pierre Benoit
Pierre Benoit on 17 Sep 2014
Edited: Pierre Benoit on 17 Sep 2014
The only other topic I found about this was this.


Richard on 17 Sep 2014
Thanks, Pierre. I ended up reading them in to 'R', then saving as a CSV which imports easily into MATLAB. Since I am new to 'R', it took me some time to generate the appropriate code. Here is an example:
> load(“kidneydata.Rda”) % from Brad Efron's web site
> dim(kidneydata) % returns 157 x 2
> A <- t(kidneydata) % transpose array
> dim(A) % returns 2 x 157
> write(A,"kidneydata.csv",ncolumns = 2,sep = ",") % save as CSV file
> write(A,"kidneydata.csv",ncolumns = 2,sep = "\t") % to save as TSV file
Andrew on 22 Sep 2020
Now in 2020 with R studio 1.1.456, the 'write' function croaked with a mysterious "Error in cat...argument 1 (type 'list') cannot be handled by cat" error, but:
worked just fine.

Sign in to comment.


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!