R has many powerful, free features, but some tasks are easier in Matlab. If you’re a Matlab user who wants to leverage R’s capabilities without rewriting routines, there’s a simple solution: run R code directly from Matlab. Here’s how:

  1. Install a working version of R on your Mac.
  2. Save your R commands to a text file using Word or another text editor.
  3. Access R through the Unix interface in Matlab and execute the file as a batch command.
  4. Save any output—like matrices or statistics—directly from the R code.
  5. Retrieve results back in Matlab for further use.

The Matlab code is simple enough that I didn’t bundle it into a function, but it’s a time-saver and might help others.