Jump to main content.

R Guide for psurvey.analysis_2.9

Downloading, Starting, Installing and Starting psurvey.analysis, R Introductory example, Script Editors

Download R Guide2.9 (pdf 29KB)

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 (version 2.2.1) is available for downloading from this site. The EMAP Design Team has not verified that the current versions of psurvey.design (2.2.1) or psurvey.analysis (2.9) are compatable with the several versions of the R Statistical Software. The Team has developed and executed these versions using R 2.2.1. Use of R version 2.2.1 is highly recommended and is available for download from this website.The process for downloading and installing follows.

  • Download R software R-2.2.10-win32, (exe 26.8 MB) [version 2.2.1, Windows (95 and later)]
  • Changes.R-2.2.1 [txt 12 KB] to read about new features of this version.
  • ReadME.R-2.2.1 [txt, 11 kb] to read about installation and usage of this version.
  • Uninstall any previous versions of R and close all programs before completing the next step.
  • Install the file by clicking on "R-2.2.1-win32". This is a Windows 2000 style installer.
  • Follow the standard installation instructions, which will put R into your Start Menu and place an R icon on your Desktop. Installation may take several minutes.
  • At this point R is installed. When R is started, a standard Help menu is available that contains documentation on R.
  • Additional documentation about R is provided on the CRAN web site under the heading "Documentation". Click on "Contributed" to display a list of user-contributed documentation.
  • 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 created for each project.

    To configure R for use with a project, proceed as follows:

    Start R, from the File pulldown menu, select Change Dir, and browse to the project folder. These steps will need to be repeated each time R is used for that project.


  • Place a copy of the Desktop icon for R in the project folder.
  • Right click on the R icon in the folder.
  • Click on "Properties".
  • Click on the "Shortcut" tab.
  • In the "Start in:" dialog box, type the directory path for the project folder, e.g., "C:\Documents\Project1".
  • Click on "OK".
  • To start R, click on the R icon in the project folder. R will automatically reference the project folder when accessing and creating data files, thus requiring the setup only once.

    Installing and using R library: psurvey.analysis

  • Obtain a copy of "psurvey.analysis_2.9.zip", which is a compressed archive (zip) file containing the library. This file may also be obtained from the Monitoring Design and Analysis section of the U.S. Environmental Protection Agency Aquatic Resources Monitoring web site: Software or from an email to Tony Olsen: Olsen.Tony@epa.gov.
  • Start R.
  • Click on "Packages".
  • Click on "Install packages from local zip file...".
  • Browse to find "psurvey.analysis_2.9.zip", select it, and click on "Open".
  • R unzips the file and installs the package in a folder named "psurvey.analysis" under the "library" folder of the R software folder. The "library" folder contains all of the packages that are installed in R.
  • Installation of the package only needs to be done once.
  • Each time R is started in a session, you have to separately "load" the package in order to access the functions and their help files.
  • To do this, click on "Packages" again and select "Load package...". Then select "psurvey.analysis" from the menu and click on "OK". The package is loaded and ready for use.
  • 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 "psurvey.analysis").
  • R Introductory Example

    A Word document with an annotated copy of the R session, R script and data file are provided to illustrate several of the R commands that are used to read, modify and select data. Download the example, r_intro_exam (zip 212KB), unzip, start R, change directory, load psurvey.analysis, open the R script file (R_Script_Intro.R) and run each segment to illustrate the commands, while following the annotated document (R Introduction.doc).

    Script and Text Editors

    Using the R script capability or a text editor is recommended for use in conjunction with R. Placing all R commands used in a script or text file will document how the analysis was completed. If necessary, the commands can be re-executed to duplicate any result or to redo an analysis if data has changed.

    An advantage to using R script is the ability to highlight commands and execute them by clicking on the "run line or selections" icon on the menu bar.

    One text editor that is tailored for use in connection with R and SPlus is TINN-R. It has a toolbar that sends script to R, lists arguments for R functions, sources files, lists contents for R objects, opens help files among other things. Highlights text for R commands, comments, identifies () matches, etc. It is a free download from sciviews.

    Notepad is available within Windows as one option. Another option is to download NoteTab Light from the NoteTab web site: Notetab.

    Local Navigation

    Jump to main content.