Starting R

R runs on the Cent-OS Department of Astronomy computers.  To start the program, type
at the command prompt.  R will start in the window.  To get help on, for instance, the plot command, type
You can then scroll up and down in the window, perhaps copying one of the examples at the bottom, and then quit by typing
You can search for a command topic with"plot")
to get all the help pages involving the word plot.  

If you have set the environment variable for the browser (see below), you can type
for a nice HTML browser that links to command searches and documentation including "An Introduction to R."

Apropos plotting, see
To quit R, type
It will ask if you want to save the environment.  Answering yes saves the command history (see history) and whatever variables are in the working memory (see ls).  You can delete the variables in memory with rm(list=ls()) if you want to save the history but not the stuff in memory.

Quick notes on installing and using R packages

R comes with a pretty comprehensive set of  functions in its base "packages," but there are over 1500 additional packages contributed by users.  Some provide special functions, others code for specific applications, some contain the routines for books.  FITSio is a package for reading and writing FITS files, for instance.  Downloading and installing the packages is easy.

Set up a local user library directory and environment variables

mkdir Rlibs
Then, either add the following to your .csh file or type at the command line (for just the session)
setenv R_LIBS_USER ~/Rlibs 
setenv R_BROWSER /local/bin/firefox
setenv R_PAPERSIZE 'letter'

Installing a package from a CRAN repository

Start R, then
       (you will probably need to wait a little for the repository drop-down to appear, then select repository)

    Now that the package is installed, you load it with the command
     To get information on the package and its functions, type
      at the R command line.
      There is an "index" key at the bottom of the page to show you the different commands, or for a specific command, type

To remove a package

remove.packages('mypkg' [, lib='~/Rlibs'])

Questions or comments?  Please contact Andrew Harris.