Notes on R for Mac OSX


Contents

  1. Installation
  2. Getting started
  3. Resources
  4. Start-up files
  5. Dealing with multiple projects
  6. Hints


Installation

  1. Download the file R-2.7.1.dmg, or the equivalent, from http://cran.us.r-project.org/bin/macosx.

  2. Run R-2.7.1.dmg by double-clicking on it.

  3. R will be installed to your Applications folder.

[Back to top]


Getting started

  1. Start R by double-clicking on the program in your Applications folder, or in the Dock, if you put it there.

    The R graphical user interface (GUI) will open, containing a single window called the console window.
    The greater-than sign ( > ) is R's "prompt;" it indicates that R is ready for you to enter commands.

  2. Look at some of the freely-available resources for R.

  3. Getting help within R:

    1. Within R, use the menu bar: Help:R help.

    2. At the command prompt, type, for example, ?read.table or help(read.table) to get help on the function read.table.

    3. At the command prompt, type, for example, help.search("read") or apropos("read") to search for things in R related to the word "read."

  4. You can exit R in at least three ways:

    1. Click on the red dot in the top-left corner of the console window.

    2. Type q() at the command prompt.

    3. Use the menu bar: R:Quit R.

    You will be asked, "Save workspace image?" Click "Save" to save your work, "Don't Save" to discard your work, or "Cancel" to return to R.

[Back to top]


Resources

The following is a subset of the resources available for learning and using R.

  1. Comprehensive R Archive Network (CRAN)

  2. R manuals:
    1. An introduction to R
    2. R installation and administration
    3. R data import/export
    4. The R language definition

  3. Contributed documentation:
    1. SimpleR (John Verzani)
    2. Kickstarting R (Jim Lemon)
    3. Using R for data analysis and graphics (John Maindonald)

  4. Frequently asked questions:
    1. R FAQ
    2. R Mac OSX FAQ

  5. Publications related to R:
    1. WN Venables and BD Ripley (2002) Modern applied statistics with S, 4th edition. Springer [Online complements]
    2. P Dalgaard (2008) Introductory statistics with R, 2nd edition Springer
    3. AF Zuur, EN Ieno, EHWG Meesters (2009) A beginner's guide to R, Springer
    4. MJ Crawley (2007) The R book, Wiley
    5. BS Everitt, T Hothorn (2006) A handbook of statistical analyses using R, Chapman & Hall/CRC
    6. J Maindonald, J Braun (2006) Data analysis and graphics using R, 2nd edition, Cambridge University Press
    7. J Verzani (2004) Using R for introductory statistics, Chapman & Hall/CRC

  6. R email lists

  7. R newsletter

[Back to top]


Start-up files

For the efficient use of R (on your own computer), it is useful to create a couple of start-up files, in order to set some default options or run some R commands automatically.

The file ~/.Renviron is used to set certain environment variables for R. I recommend a file containing the following line, since, by default, R may assume that you want A4 paper.

R_PAPERSIZE=letter

The file ~/.Rprofile is assumed to contain R code, which is run at start-up. I recommend including something like the following (to turn off the asterices that show up in significance tests). You may also use this to automatically load an optional package.

options(show.signif.stars=FALSE)

[Back to top]


Dealing with multiple projects

R keeps your "workspace" of objects in a single file (.RData), which is read into RAM when R is started and potentially written to disk at the end of a session. (Note: To save your workspace without exiting, type save.image() at the R prompt. It is good to do this periodically, so that your work is saved in case that R or your computer crashes.)

One may wish to have multiple R workspaces (i.e., .RData files), one for each project or data set. In Mac OSX, we do this as follows:

  1. Create multiple folders (i.e., directories), one for each project (for example, ~/Rwork/Project1 and ~/Rwork/Project2).

  2. In R, use the Misc menu to change your working directory, and use the Workspace menu to load or save a workspace file.

[Back to top]


Hints

[Back to top]


Back to home page

Last modified: Mon Jun 29 23:50:21 2009