Some Tips on Getting Acquainted with R (stream of consciousness)

Install R: go to then click on

Windows (95 and later)

Then click on base.

Then download R-2.3.1-win32.exe and run it in order to install it. Follow the installation commands.

You should have an R icon on the desk top. Double click it to open up a session. Make a directory somewhere for holding your practice R workspace. Call the directory “Practice” or whatever.

In the R session under the File menu (top bar) choose

Change dir … and browse to the Practice directory and choose it as your new directory for this session. Type q() on the command line and save the work space when prompted. This ends the R session. You should see an R icon in your Practice directory. By double clicking on it you open up that session again.

Please explore on your own, once you have installed R.

On the command line type help.start(). This opens up a web based help facility with R. Explore it a little.

You can also get help on any specific command (provided you know its name, say mean) by typing ?mean. See what it gives you.

Objects in R are either data sets of functions. You can import data from an Excel csv file by using read.csv. Explore ?read.csv or use the web based help.

Create a simple function as follows: Type at the command line:

Sq = function(x){x^2}

Execute Sq(2) on the command line. Execute 1:5 on the command line. Execute Sq(1:5) on the command line. You could also have created a function via the R editor, say fix(Cube) which opens up an edit window, e.g.,

function ()

{

}

Modify it to look like

function (x)

{

X^3

}

and save the result. You should now see two (function) objects in your work space when you type ls(), namely Sq and Cube. Type Cube(1:5). Type just Cube, it will spool by the function definition. Type Cube() and it will complain that something is missing.

You can clear all objects from your work space by typing rm(list=ls())

Type x=rnorm(100) and then hist(x). You can save the graphic in various file formats (highlight the graphics window first by clicking on it), or you can put it on the clip board for usage in Word or other documents that let you cut and paste.

Explore: ?matrix, ?data.frame, ?attributes, ?dim, ?mode

How to install a package: If you downloaded the package in zip format from CRAN or from my web page for Stat421, put it in the directory where the R work space sits. In the R session choose Packages on the top bar, the choose install from local zip files.

Pick the appropriate zip file in the dialog box and install.

Before such a package (such as combinat) becomes active you have to put library(combinat) on the command line. Then you should see something under combinate in the packages section of the web based help tool.

Or type ?combn and it should show you something.

To be continued.