Workshop on the R System - Preparation

These notes are intended for anyone planning to attend one of the R course that I run from time to time, or wanting to test the water for possible attendance at such a course.

In preparation for the Course

Copy down the R binary, install it on your machine, start up R, and start typing!
Windows users: Click here to obtain R

Other systems, click here, and check whether a binary is available for your system.

See also the document Installation of R, of R packages, and editor environments

What should I type?

> 1+1
This may suggest some other possibilities!
> nn <- 1:5
Create in the workspace an integer vector nn that holds the values 1,2,3,4,5.
NB: <- is the assignment symbol.
> nn Display (print) the contents of nn
> ls() Show the contents of the workspace. You should see "nn" listed.
> q() End (quit) the session. When asked if you want to save the workspace, make a habit of clicking on "Yes". This saves everything in the workspace into a file (called .RData, for those who really must know) in the working directory.

Before too long, there will be a need to know the path to the working directory. Start R again (the workspace, if saved on the previous exit, gets reloaded), and type:
> ls() Show the contents of the workspace.
> getwd() Get the path to the working directory
If not set or changed from the default, Windows systems are likely to use "C:/Documents and Settings/Owner/My Documents" as the working directory. Other uses for working directories (there can be as many as you want) will become apparent as the course proceeds.

There are a number of demonstrations to try.
> demo() Gives a list of demos that can be tried
> demo(graphics) Show off the graphics. Press the ENTER key to display the first graph,
and to display each successive graph.

Packages that should be installed

Those who bring laptops should ideally arrive with their laptops ready set up for use. After installing R, install also the packages animation, DAAG, DAAGxtras, latticist, latticeExtra and Rcmdr. Ideally, install also ggplot2. Several of these packages have a number of dependencies.

To check, e.g., that latticeExtra (and dependencies) is properly installed, start R and type, on the command line:
  library(latticeExtra)

Other packages to which there may be reference include dichromat, fortunes, odfWeave, scatterplot3d and schoolmath. For longer courses (2 days or more), it may be useful, depending on the focus of the course, to install ade4, ape (requires gee), lme4, randomForest, playwith, rpanel, rgui, and rattle.

For playwith, and preferably also for rattle, GTk+ should be installed.

Get GTK+ from http://downloads.sourceforge.net/gladewin32/. Currently, download and install the binary gtk-dev-2.12.9-win32-1.exe.

If R has access to a live internet connection, packages can be installed from the menu. You will need to select a repository. In Australia, choose an Australian repository. Alternatively, packages can be installed from the command line. For Rcmdr, a suitable command is:
  install.packages("Rcmdr", dependencies=TRUE)
The R commander has many dependencies, indirect as well as direct. Unless the internet connection is fast, this may take some time.

Installation of Packages (or even running R) from a DVD

DVDs and memory sticks will however be available at the course from which it will be possible to install, from R-2.8.0 or R-2.8.1, any packages that are lacking. Additionally, these DVDs will include an R executable that has relevant packages already installed. Once the DVD is in a computer's DVD drive, R can be run from the DVD.

What next?

Work through chapters 1 and 2, and preferably also chapter 3, of the document
http://www.maths.anu.edu.au/~johnm/courses/r/notes/rnotes1-24.pdf

Click here to get the scripts

Do you have data that you are happy to expose to wider view?

Contact the presenter with the details. Data that have been used for a published paper may be especially suitable.

Links

Introductions to R; Futher exercises; Here's a challenge: Weaving documents with R!

Web site for R (CRAN = Comprehensive R Archive Network)

John Maindonald's web site

email: john.maindonald AT anu.edu.au
Last updated: Feb 20 2009.