R:Installing and Using R and Rcmdr on a MAC

From MathWiki

This file contains information on installing and using R (http://www.r-project.org/) and Rcmdr (http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/) on a computer running Mac OS X. Mac users in NATS 1500 and MATH 1532 (Winter 2010) encountered issues getting Rcmdr to work after following the installation notes (http://socserv.mcmaster.ca/jfox/Misc/Rcmdr/installation-notes.html). Edvin Vitaj in NATS 1500 prepared the following notes to help with the installation.

In contrast with the version of Rcmdr on the PC, the version on the Mac does not import Excel files. Course datasets need to be downloaded as comma-separated text files. Instruction for downloading these files are given below.

Table of contents

Installing R and Rcmdr

  • To install it just double click on the downloaded file and follow the usual steps as with any application.
  • When the installation is finished, run the application (R64.app), select from the menu Packages & Data, then from the drop down menu select Package Installer.
  • A new window will open, an image of the window is shown below. In the right corner there is a box similar to the google search window in a web browser, type in there Rcmdr.
  • On the left side, there is a button Get List, by clicking we select the Ontario, Canada and then click enter.
  • A list will show up, select the first one, and before clicking Install Selected, the box under it Install dependencie should be checked. See the image which you can enlarge by clicking on it. There is a red dot in the image for every point mentioned above.


Image:Installing_Rcmdr_on_a_MAC.png


  • After clicking "Install Selected", it will take more than 2 minutes with a fast internet connection to finish so you should wait until the '>' sign is shown in the R Console.
  • Then we type library(Rcmdr) command and the R Commander window should pop up.
  • In the case that nothing happens, the R Commander window does not pop up, you should make sure that "X11" application is running. You can run "X11" before you run R, or you can run R first and then you will see in R Console the "X11 button". It is the fourth button, a white icon with an X in it.
  • Click that button and then issue library(Rcmdr) command. "X11" will run in background, so you don't have to worry or do anything else with it.
  • If "X11" is not already installed in your machine, you can find it in the DVD installer disc that came with your computer, or you can download it from apple site. From the Mac OS X Tiger, "X11" is included in the DVD installers disc. For an older Mac OS X operating system, try this link which maybe will help you: http://www.apple.com/downloads/macosx/apple/macosx_updates/x11formacosx.html

TclTk problems

If, when you type

library(Rcmdr)

R produces a message along the lines of:

Loading Tcl/Tk interface ... Error in dyn.load(file, DLLpath = DLLpath, ...) :
  unable to load shared library
you may need to install Tcl/Tk. Go to http://cran.r-project.org/bin/macosx/tools/ and install the second file tcltk-8.5.5-x11.dmg (http://cran.r-project.org/bin/macosx/tools/tcltk-8.5.5-x11.dmg)
Enlarge
(photo on right) or whatever the current updated version happens to be.

After doing this, restart R and try to start Rcmdr again with:

 library(Rcmdr)

Downloading data sets

On a PC, Rcmdr can read Excel files directly. On a Mac, Excel file (.XLS) can be read with Excel or Numbers, if installed, and exported as comma-delimited text files (CSV files). These files can be read by Rcmdr as described below. Alternatively, comma-separated text files can be downloaded directly and read by Rcmdr. Comma-delimited text files for the data sets in the textbook for NATS 1500 and MATH 1532 are available at http://www.math.yorku.ca/people/georges/Files/NATS1500/Data/DataCSV_forMac/.

Reading comma-delimited text files

To read a comma-delimited text file with Rcmdr, use Data | Import data | from text file, clipboard or URL:


Image:RcmdrSelect.png


then, instead of the White space default, select Commas for the field separator.


Image:CommaSelect.png


Finally click OK and select the file you previously downloaded.