Install R
R is a free open-shareware software that can run on Unix, Windows, or Mac OS X computer operating systems. The R software can be downloaded from the Comprehensive R Archive Network (CRAN) which is located at: http://cran.r-project.org/ . There are several sites or servers around the world where the software can be downloaded, which is accessed at: http://cran.r-project.org/mirrors.html . The R version for Windows will be used in the book, so if using Linux or Mac OS X operating systems follow the instructions on the CRAN website.
After entering the URL: http://cran.r-project.org / you should see the following screen.
Download and Install R
Precompiled binary distributions of the base system and contributed packages, Windows and Mac users most likely want one of these versions of R:
Download R for Linux ( http://cran.r-project.org/bin/linux/ )
Download R for MacOS X ( http://cran.r-project.org/bin/macosx/ )
Download R for Windows ( http://cran.r-project.org/bin/windows/ )
After clicking on the Download R for Windows , the following screen should appear where you will click on base to go to the next screen for further instructions.
R for Windows
Subdirectories:
base ( http://cran.r-project.org/bin/windows/base/ ) | Binaries for base distribution (managed by Duncan Murdoch). This is what you want if you install R for the first time ( http://cran.r-project.org/bin/windows/base/ ) |
contrib ( http://cran.r-project.org/bin/windows/contrib/ ) | Binaries of contributed packages (managed by Uwe Ligges) |
You may also want to read the R FAQ ( http://cran.r-project.org/doc/FAQ/R-FAQ.html ) and R for Windows FAQ ( http://cran.r-project.org/bin/windows/base/rw-FAQ.html ).
After clicking on base , the following screen should appear to download the Windows installer executable file, e.g. R-2.15.1-win.exe (The version of R available for download will change periodically as updates become available, this is version 2.15.1 for Windows).
R-2.15.1 for Windows (32/64 bit)
Download R 2.15.1 for Windows ( http://cran.r-project.org/bin/windows/base/R-2.13.1-win.exe ) (47 megabytes, 32/64 bit)
Installation and other instructions ( http://cran.r-project.org/bin/windows/base/README.R-2.13.1 )
New features in this version: Windows specific ( http://cran.r-project.org/bin/windows/base/CHANGES.R-2.13.1.html ), all platforms ( http://cran.r-project.org/bin/windows/base/NEWS.R-2.13.1.html ).
Run the executable file by double-clicking on the file name (R-2.15.1-win.exe) once it has been downloaded to install, which will open the R for Windows setup wizard.
NOTE: The Download R 2.xx.x for Windows version will have changed to newer versions, so simply download the latest version offered.
Install R Studio
The R Studio interface, which is installed after installing the R software, provides an easy to use GUI windows interface (Graphical User Interface), download from: http://www.rstudio.org/ (Must have R2.13.1 or higher version on PC, Linux, or Mac OS X 10.5 before download and install of this software). The following desktop icon will appear after installation.
The R Studio window provides the usual R console. It also provides a workspace/history window with load/save/import data set features. Another window provides easy access to files and a list of packages available. The Plots tab also shows a created plot and permits easy Export to a GIF image, PDF file, or copy to the clipboard feature to insert into a Word document.
Getting Help
The R software contains additional manuals, references, and material accessed by issuing the following command in the RGui window once R is installed:
Load R Packages
Once R is installed and the RGui window appears, you can load R packages with routines or programs that are not in the base package. Simply click on Packages in the main menu of the RGui window, and then make your selection, e.g., Load packages .
A dialog box will appear which lists the base package along with an alphabetical list of other packages. I selected stats from the list and clicked OK. This makes available all of the routines or commands in the stats package. Alternatively, prior to entering R commands in the R Console window, you can load the package from a library with the command:
To obtain information about the R stats package issue the following command in the R Console:
> help(stats)
or
> library(help= stats)
which will provide a list of the functions or routines in the stats package. An index of the statistical functions available in the stats package will appear in a separate dialog box.
Running R Programs
To run R programs in the book, you will Click on File , then select Open script from the main menu in the RGui window. For example, locate and select chap01_Begin.r script file, which then opens in a separate R Editor window.
Next, click on Edit in the pull down menu and select run all , to execute all of the command lines in the program. The Editor Window will show: