University of Minnesota, Twin Cities School of Statistics Stat 5601 Rweb
To download R go to CRAN (the Comprehensive R Archive Network) at
http://cran.r-project.orgor one of the mirror sites listed there. In particular the US mirror is
http://cran.us.r-project.org
Follow the intructions on the CRAN web pages. There are precompiled binaries for various forms of Windows (95, 98, NT, and 2000) and various forms of UNIX (including Linux).
Go to
http://cran.us.r-project.org/bin/windows/base/read the ReadMe files there and follow the instructions.
Go to
http://cran.us.r-project.org/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 RedHat 6.x Linux on an Intel-compatible box, for example,
you get the file
http://cran.us.r-project.org/bin/linux/redhat/7.x/i386/R-base-1.3.0-1.i386.rpm(or something similar, the version numbers change with each release). Then you just install it in the usual way: as root do
rpm -i R-base-1.3.0-1.i386.rpmMore generally, read the ReadMe files there and follow the instructions.
If you really want to know how to use R, you will have to download and print out the manuals from
http://cran.us.r-project.org/manuals.htmlor buy and read one of the books listed on
http://www.r-project.org/books.htmlWe 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.
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.txtRweb, being a web application can read URLs. R, not being a web application, can't. What to do?
First, download the data file to your computer (using a web browser).
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
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))
It should also be obvious that you can also read in files in the same format, each variable is one column of the file, the columns separated by white space, the variable name at the top of each column (that is, the first line of the file gives the variable names) that you yourself have created with a text editor or whatever.
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).
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.
Just click on the Rgui icon that the R installation process puts on the desktop.
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.
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.