R Guide for psurvey.design_2.2.1
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)
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.
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:
- 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.Alternative:
- After starting R, under the File pulldown menu, select "Change Dir..."
- Browse to the project folder and click "OK"
- These steps will need to be repeated each time a new analysis is started for this project.
- Obtain a copy of "psurvey.design_2.2.1.zip", which is a compressed archive (zip) file containing the library. This file may 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.design.2.2.1.zip", select it, and click on "Open".
- R unzips the file and installs the package in a folder named "psurvey.design" under the "library" folder of the R software folder. The "library" folder contains all of the packages that are installed in R.
- Browse to find "sp_0.8-4.zip", select it, and click "Open"
- Installation of these packages only needs to be done once.
- Each time R is started in a session, you have to separately "load" the packages in order to access the functions and their help files.
- To do this, click on "Packages" again and select "Load package...".
- Then select "sp" from the menu and click on "OK"
- Redo these steps and select "psurvey.design" from the menu and click on "OK".
- The packages are 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.design").
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.
Notepad is available within Windows as one option. Another option is to download NoteTab Light from the NoteTab web site: Notetab.
The R package now includes script files which largely replace the above text file recommendation. The design examples include R script files, which are easily opened from the File pulldown memu. Highlighting the commands within the script file and then clicking the "Run line or Selection" button is an easy method of excuting the psurvey.design R commands.