ACSPRI Course: Data Analysis, Graphics and Visualisation Using R

Participants will be expected to bring their own laptops (PC or MacOS X or Linux), with a recent version of R (preferably R-2.15.0 or more recent) already installed.

Note that administrator privileges are not required for installation of R. In the absence of administrator privileges, R will be installed into a user directory.
  Windows users: Click here to obtain R

  Other systems, click here to look for a binary for your system (MacOS X, some flavours of Linux).
Additionally, a number of R packages should be installed. For details of R Packages that should be installed, click here

In preparation for the Course - Getting Familiar with R

Intending participants with limited previous experience with R, or with no previous experience of R. should do some modest amount of preliminary familiarisation. Copy down the R binary, install it on your machine, start up R, and start typing!

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.

There will at some point 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.

Tutorial Material for R

Start working through the document
  http://www.maths.anu.edu.au/~johnm/courses/r/notes/rn1-34.pdf

  Click here to get scripts

Other Introductory Documents from the Web

Go to http://cran.csiro.au and click on Documentation to see some of the possibilities.

Try, perhaps, R for Beginners (Emmanuel Paradis).

R Packages that should be installed

After installing R, install also the packages animation, DAAG, fortunes, latticist, latticeExtra, playwith, rgl, Rcmdr, Ecdat, oz, googleVis, dismo, rJava, sp, fgui and ggplot2. Several of these packages have a number of dependencies, so that other packages will be installed along with them. Mac users who install from the Mac GUI should be sure to tick the box "Install dependencies".

Other packages to which there may be reference include dichromat, odfWeave, rpanel, scatterplot3d, and schoolmath

For playwith, GTk2 should be installed. NB: Gtk2 is not part of R. It is required in order to use the abilities, or some of the abilities, in certain R packages

For R under Windows (requires R-2.12 or later), download and install http://downloads.sourceforge.net/gtk-win/gtk2-runtime-2.24.8-2011-12-03-ash.exe

For use with R under MacOS X, download and install http://r.research.att.com/libs/GTK_2.18.5-X11.pkg

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. On a slow internet connection, this may take some time.

Installation of the RStudio Integrated Development Environment

This free and open source development environment (editor, and much more) is strongly recommended for use of R. Download it from RStudio website (Mac: ∼ 40MB; Windows: ∼ 24MB; Linux: ∼ 24MB)

Checking the Installation

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

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

Flash drives (or possibly DVDs) will however be available at the course from which it will be possible to install, for R-2.15.0 or later, any packages that are lacking. Additionally, these will include an R executable that has relevant packages already installed. This makes it possible, as a temporary recourse, to run R from the flash drive.

Installation of Java JDK (optional)

Certain R packages (e.g., tm for text mining) require Java JDK. While none of these packages are likely to be used in this course, anyone who wishes to experiment widely with R packages may find useful to have Java SDK installed.
Go to: http://www.oracle.com/technetwork/java/javase/downloads/index.html. Then, under Java Platform, Standard Edition, click on click on Download JDK. (This is described as Java SE6 Update 23.)

Mac users should already have JDK installed as part of the Macintosh system.

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

Further exercises; and Weaving with R (strictly for those who want some greater challenge!)

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

There are further interesting R links here.

John Maindonald's web site

email: john.maindonald AT anu.edu.au
Last updated: May 11 2012.