University of Minnesota
Statistics
info@stat.umn.edu
612-625-8046


School of Statistics' home page.

Run a Large Simulation without Angering the Administrators

University of Minnesota, Twin Cities     School of Statistics     Rweb

Contents

Downloading R

To download R go to CRAN (the Comprehensive R Archive Network) at

http://cran.r-project.org

or one of the mirror sites listed there. The nearest mirror to Minnesota seems to be at Michigan Technological University in Houghton, MI. If you are not in Minnesota, you should use a mirror near you.

http://www.biometrics.mtu.edu/CRAN/

Follow the intructions on the CRAN web pages. There are precompiled binaries for various forms of Windows (95, 98, NT, 2000, XP), various forms of UNIX (including Linux), and Macintosh (OS X).

Downloading R for Windows

Go to

http://www.biometrics.mtu.edu/CRAN/bin/windows/base/

read the README.R-2.3.1 files there and follow the instructions.

Downloading R for Linux

Go to

http://www.biometrics.mtu.edu/CRAN/bin/linux/

and choose the subdirectory that matches your distribution (and keep going down to further subdirectories until you find an rpm file or whatever binary format the distribution prefers. If you have SuSE 10.0 Linux on an Intel-compatible box, for example, you get the file

http://www.biometrics.mtu.edu/CRAN/bin/linux/suse/10.0/RPMS/i586/R-base-2.3.1-0.i586.rpm

(or something similar, the version numbers change with each release). Then you just install it in the usual way: as root do

rpm --install --test R-base-2.3.1-0.i586.rpm

and if you get no complaints remove the --test (which says don't really do it, just see if you can do it) and redo

rpm --install R-base-2.3.1-0.i586.rpm

With SuSE 10.0 you will probably find that you need to install some more packages, some of which are not found on the free OpenSuSE DVD but only on the one they sell. So you will either need to buy or borrow that.

More generally, read the read me files and follow the instructions.

Downloading R for Macintosh

I have no experience with this. Just follow the instructions at http://www.biometrics.mtu.edu/CRAN/bin/macosx/. I can't tell you any more than that.

Installing or Updating Packages

The default install of R only adds a few packages. There are lots of others available at CRAN. Many are used in various courses that use R.

It is very easy to install additional packages. When your computer is connected to the internet, go into R and do

install.packages("exactRankTests")

or the same command with any other package name in quotes. The install should just work. You don't need to know anything else.

Using R

General

If you really want to know how to use R, you will have to download and print out the manuals from

http://www.biometrics.mtu.edu/CRAN/manuals.html

In particular, An Introduction to R is well worth reading. If you read and digest that you will be on the borderline between knowledgeable user and expert. This can also be downloaded (from the manuals page above) as a PDF file and printed on any laser printer.

Or buy and read one of the books listed on

http://www.r-project.org/doc/bib/R-books.html

We can't tell you how to use a really complicated computing language in one web page.

What we can do is tell you how, at least, to do whatever you were able to do in Rweb using R on your own computer.

Reading Data Files off the Web

The main issue is: How does Rweb read in the data, and how do I do the same thing?

Suppose Rweb is loading the data from a URL, say

http://www.stat.umn.edu/geyer/somedata.txt

You can do exactly the same thing as Rweb does with the code

X <- read.table(url("http://www.stat.umn.edu/geyer/somedata.txt"), header=TRUE)
attach(X)

(assuming your computer is connected to the internet at the time).

By the way, the X here is just a variable name. You could replace it with fred or sally or whatever. Of course, you must replace both occurrences!

Reading Local Data Files

But suppose you want to read a local file. Say one you have downloaded or one you have created with a text editor.

First it must be a plain text file. You can't use a so-called word processor like Microsoft Word to create the file. Its default file format has lots of garbage in it, definitely not plain text. (Actually, it can be forced to write out plain text if you try hard enough, but I won't bother to tell you how). Use a text editor (like Notepad on Microsoft boxes).

Then, inside R you use the read.table function to read in the data, just like Rweb does. For example, if the file somedata.txt downloaded from the web is in the current working directory, the following works.

X <- read.table("somedata.txt", header=TRUE)
attach(X)
plot(x, y)
abline(lm(y ~ x))

On-Line Help

When you start up R, it tells you how to get on line help, for example

help(rnorm)

displays the help for the function rnorm, and

help.start()

starts a web browser pointing to the R help in web format (HTML).

Quitting and Saving Your Work

You quit R by typing the function

q()

as R says every time it starts up. You can also select "Exit" on the "File" menu of the Rgui program in Windows.

Before the program quits it asks

Save workspace image? [y/n/c]:

Type "y" to save your work. All the variables you have currently defined will be saved and reloaded when you start R again. Or type "n" to quit without saving.

Using R (Windows specific)

Starting R

Just click on the Rgui icon that the R installation process puts on the desktop.

Working Directory

Set the working directory to the folder containing files you want to read by selecting "Change dir" on the "File" menu of the Rgui program.

Using R (UNIX specific)

Starting R

The name of the program is "R". Just type "R" at a UNIX prompt.

Putting it on a menu or as a desktop icon is a bit tricky. We won't try to tell you how to do that.