Can you use R to replace MATLAB?


Sean Gerrish will give a tutorial on Tuesday 9/02. Same room and same time as the usual tuesday lectures.

Using R at Princeton

You can find copies of R for your personal computer at It is also installed on the CS linux machines (e.g., and ) and the hats machines (

Sample scripts, data, etc.

  1. The slides of the 2008 tutorial are available here.
  2. An example R script (with comments) can be found here.
  3. The commands used in the tutorial can be found here.
  4. The movies dataset (included in the ggplot2 package) can be found here.

About R

“R is a system for statistical computation and graphics. It consists of a language plus a run-time environment with graphics, a debugger, access to certain system functions, and the ability to run programs stored in script files.”

To properly prepare yourself for the class, the first thing you should do is download and install the program. Familiarize yourself with how to run it. Start working through the Introduction to R (if you actually make it all the way through, you'll be more than prepared). Those of you familiar with Matlab should find transitioning to R fairly easy. But like most systems, the best way to learn is to dive in and start playing around with it.


  1. High-level introduction to R: what is it good for?
  2. R syntax and data structures
  3. R syntax examples (session)
  4. Graphics in R
  5. Graphics xamples (session)

Useful links

  1. The R Project for Statistical ComputingThe main page for the R project.
  2. RSeek.orgA search engine for R related materials.
  3. ESS: Emacs Speaks StatisticsAdd-ons for emacs that allow it to interface with R.
  4. An Introduction to R (PDF version available hereA good introduction/tutorial for R.
  5. R Graph GalleryA gallery of pretty graphs made with R.