Orientation
Windows in R
Launch R by selecting the program file from the Windows Start Menu. You will see a typical Windows graphical user interface (GUI) with menus and toolbars. Additionally, you will see a window called the “R Console”, or command window. The Console already has some text displayed, stating general information about the version number, licensing, citations, and help.
The prompt “>” at the end of introductory text indicates that you can begin typing commands directly in the Console window. For instance, you can type 3 + 5, press enter, and the answer will appear on the next line, followed by another prompt.
> 3 + 5 [1] 8 >
You can continue to type commands, one at each prompt, for the duration of your R session. Alternatively, you can use the R Editor to type several commands and submit them to the Command window (similar to what one might do in the SAS or SPSS syntax editors). The R Editor is accessible from the File menu (File -> New Script). Run commands from the Editor by highlighting the text, right-clicking on it and selecting Run line or selection (alternatively, highlight the text and press Ctrl+R). The R Editor is a basic text editor, and several more sophisticated editors are available. Among the alternatives for the Windows platform are Tinn-R, WinEdt and Vim. Consult the CRAN site for a complete list of script editors and their features. Emacs Speaks Statistics (ESS) is an add-on package for the Emacs editor; it allows you to edit text and send commands directly to R. You can also copy/paste text into the Console from the Notepad text editor in Windows.
Menus in R
The drop-down menus allow you to customize your working environment. The “Change dir…” item in the File menu enables you to set the working directory for the current session of R. You may want to change this if you plan on opening or saving files from a particular storage location during your session. The GUI preferences under Edit will allow you to configure the console, graphics windows and editor. Under Help, you can access the R manuals in pdf format and seek help in the R online archives. Under Packages, you can set the CRAN mirror and select repositories for installing new packages, as discussed in the next section.
Packages
The R program you downloaded from CRAN contains the base R packages, which include some basic statistical commands and graphics utilities. For many types of statistical analyses, you will need to install additional packages. For instance, in order to work with regression splines on your data points, you may need to install and load the “splines” package. You can do so from the drop-down menu (Packages -> Install packages). When you choose this menu option, you will be asked to select a CRAN mirror; you may choose any mirror that you like, but it makes sense to choose a mirror that is not too far from you geographically. After you have selected a mirror and pressed “OK”, a list of packages will appear. Find the package you are interested in using, and press “OK”. You will see that there is new text in the Command window displaying the details of the package download and installation. Before using a package, you must load it for the current working session. You may do this by choosing (Packages-> Load package) from the Packages menu, or by typing: library(pkgname) at the prompt, where pkgname should be replaced by the name of the package you want to load. Once you have installed a package on your system, you will NOT need to re-install it each time you want to use it. You WILL, however, need to re-load the package every time you start a new R session in which you want to use it. Consult the CRAN site for a list of R packages available for download.
Next: Preparing Data for Analysis
Prev: Introduction
Up: Table of Contents



