Installation
UNIX/Linux     Windows     Mac OS
Loading into R
UNIX/Linux     Windows     Mac OS
Using the toolkit
Tutorial (pdf)     Tutorial (html)
Example Datasets
Updates
What's New?    

Subscribe to electr onic mailing list
R software
R project     What is R?
Extreme Values Page
Return
Back to Main Page

R basics

For the most part, R code is identical across platforms. However, there are differences in appearance between Windows, Mac and Unix/Linux platforms, but almost every command (if not all of them) is the same. Below are some basic commands to assist you in using the extRemes toolkit, which does not require much knowledge of the R programming language to use effectively. For a more thorough introduction to R, please see "An Introduction to R" at the R project home page (click on Manuals under Documentation) at: http://www.r-project.org/

To begin an R session in Windows, find the R icon or start menu button and click/double click on it as you would any other program in Windows. Note that R version >= 1.7.0 for Windows is required as it installs and configures the necessary (for this toolkit) Tcl/Tk software automatically.

To begin an R session in Unix or Linux, type the capital letter R from the command prompt.

Note that all R commands are functions, so they must be followed by a set of parentheses, which may be empty if there are no parameters to be entered. For example,

> date()
[1] "Tue Jul 8 14:02:33 2003"

If the parentheses are not given, then the source code of the function will be given. For example,

> date
function ()
.Internal(date())


If there are arguments to pass to the function, these are listed inside the parentheses. For example,

> plot(x=1:10)

The last command should produce an uninteresting plot of one-to-one points. to list out the arguments to any function, the args caommand is useful. For example,

> args( plot)
function (x, y, ...)
NULL

> args( rnorm)
function (n, mean = 0, sd = 1)
NULL

To get help on a function, say rnorm, type

> help( rnorm)

Or, simply

> ?rnorm

To assign a value to an object, the simplest method is to use the "<-" symbol. For example, to assign a vector of numbers from 1 to 4 to the object "foo", simply type:

> foo <- 1:4

To check the contents of foo, type:

> foo
[1] 1 2 3 4

Ignore the [1] here. It indicates that it is the first row of a vector (i.e., with only one row). The object foo is (temporarily) assigned to the current working directory. To see what the current working directory is, type:

> getwd()
[1] "/[path to current working directory shown]"

You can change the current working directory with the setwd function. It is possible to save the contents of your current working R session (e.g. to save foo for future R sessions). The saved R workspaces will be found in a file called .RData. To save the current working directory, use the command:

> save.image()

Finally, in order to exit out of R simply type:

> q()

R will ask if you wish to save the workspace image. Type 'y' for yes, 'n' for no and 'c' to cancel. It is also possible to instruct R whether to save the workspace or not in the following way:

> q("yes") # to save the workspace
> q("no") # to exit without saving the workspace.

In Windows, it is also possible to exit by clicking on the X in the upper right corner of the R gui, or by selecting Exit from the dropdown menu. Note that comments in R source code are indicated by the '#' sign.

Again, for more information about R, please refer to the R project website.