What
is R?
"R
is a language and environment for statistical computing and graphics. It is a
GNU
project which is similar to the S language and environment which was
developed at Bell Laboratories (formerly AT&T, now Lucent
Technologies) by John
Chambers and colleagues. R can be considered as a
different implementation of S.
There
are some important differences, but much code written for S runs unaltered
under R.
R
provides a wide variety of statistical (linear and nonlinear modelling,
classical
statistical tests, time-series analysis, classification, clustering,
...)
and graphical techniques, and is highly extensible. The S language is often
the
vehicle of choice for research in statistical methodology, and R provides an
Open
Source route to participation in that activity.
One
of R's strengths is the ease with which well-designed publication-quality
plots
can be produced, including mathematical symbols and formulae where needed.
Great
care has been taken over the defaults for the minor design choices in
graphics,
but the user retains full control.
R
is available as Free Software under the terms of the Free Software
Foundation's
GNU General Public License in source code form. It compiles and
runs
on a wide variety of UNIX platforms and similar systems (including FreeBSD
and
Linux), Windows and MacOS." (from "The R Project for Statistical
Computing"
web
page)
Downloading
R
The
R statistical analysis program is available for downloading from the web.
The
process for downloading and installing follows.
1.
Use a web browser to access the CRAN (Comprehensive R Archive Network)
web page: http://cran.us.r-project.org/
2.
Click on "Windows".
3.
Click on "base".
4.
Click on "Download R 2.15.0 for Windows" to begin the
download. This is
a 48 MB file so
it may take several minutes on a direct network
connection to download the file.
5.
Click on "Save File".
6. In
the window that opens, browse to the folder in which you want to save
the file and click on "Save".
7.
Uninstall any previous versions of R and close all programs before
completing the next step.
8.
Install the file by double clicking on it, which will initiate a
standard
Windows installer. Follow the installation instructions. This process
will insert an entry for R into the
Start Menu and create an R icon on
the Desktop.
9. At
this point R is installed. When R is
started, a standard Help menu is
available that contains documentation on
R.
10. Additional documentation is on the R web
page under Documentation. Under
Documentation, "Contributed"
has user-contributed documentation for
beginners. You may find one or more of these useful.
Starting
R
R
may be started from the Start Menu or from the Desktop icon. An important
aspect
in using R is to keep different projects on which you are working
separated. We recommend that a separate folder be setup
for each project. To
start R for the first time in a project:
1. Place a copy of the Desktop R icon in the
project folder.
2. Right click on the R icon in the project
folder.
3. Click on the Properties tab.
4. In the "Start in" dialog box,
type the directory path for the project
folder, e.g.,
C:\Documents\Project1
5. Start R by clicking on the R icon in the
project folder. This will make R
automatically
reference that folder when accessing and creating data
files.
After
have done this the first time, simply click on the R icon to begin in that
project folder.
Installing
and using R library: spsurvey
1. Start R.
2. Click on the "Packages" menu and
select "Install package(s) ...".
3. A list will open that displays CRAN
mirrors. Select one of the sites and
click on “OK”.
4. Select "spsurvey"
and click on "OK".
5. R will install the spsurvey
package. The package is installed in a
folder named
"spsurvey" in the "library" folder
of the R software folder.
The
library folder contains all installed packages.
In addition, R will
install five additional packages that are required by spsurvey: deldir,
plyr, rgeos,
sp, and springr.
6. Installation of the spsurvey
package only needs to be done once.
7. Each time R is started in a session, you
have to separately "load" the
spsurvey
package in order to access the functions and their help
files. To load the package, click on the "Packages"
menu and select
"Load package...".
Select "spsurvey"
and click on "OK". The package will
be loaded by R.
8.
After loading the library, help for using the functions in the library is
available
through the help command, i.e., enter "help(function name)" at
the command
line, and through the "Help" menu (click on "Help", click
on
"R functions (text)...", enter the function name, and click on
"OK").
Help for the entire library also is
available through the "Help" menu
(click on
"Help", click on "Html help", click on
"Packages", and
click on "spsurvey").
Text
Editors and R
Using
a text editor is recommended for use in conjunction with R. Placing all R
commands used in a text file will document how the analysis
was completed. If
necessary, the text file can be re-executed to duplicate any
result or to redo
an analysis if data has changed.
Although
Notepad is available with Windows, RStudio and Tinn-R provide enhancements for editing and executing files
that contain R code. Most users will
find that RStudio is especially helpful. RStudio can be
downloaded from http://www.rstudio.org/.
Tinn-R can be downloaded from http://www.sciviews.org/Tinn-R/.