Before you can begin to formulate a strategy for the Shu forces, you must ensure that your data analysis tool is in working order. Fortunately, R can be prepared for battle in a few straightforward steps.
By the end of this chapter, you will be able to:
Download R
Install R
Run R on your computer
Issue an R command
Set your R working directory
Time for action - downloading and installing R
Let us see now how to download and install R:
Browse to the official R website at http://www.r-project.org; the home page looks like the following:
Under the Download, Packages heading on the left-hand side of the screen, click on the CRAN link.
A page with several CRAN (Comprehensive R Archive Network) servers located across the world will be displayed. Click on the link for the CRAN server located nearest to you.
A page with frequently used CRAN links will be displayed. In the Download and Install R section, click on the link that corresponds to your operating system ( Linux,Mac OS X, or Windows).
Use the provided link to download the latest version of R for your operating system and version.
Note
For demonstration purposes, the Mac OS X page is shown here. As of this writing, a user on Mac OS X 10.5 or higher would click on the R-2.11.1.pkg link to download the installation package. Similarly, you should download the appropriate installation file for your operating system and version.
Double-click on the file that you downloaded in step 5. Then follow the prompts to install R on your computer.
Note
For assistance with your specific operating system, see section 2.5 How can R be installed? of the official R FAQ at http://cran.r-project.org/doc/FAQ/R-FAQ.html. This section provides documentation for installing R on the most frequently used operating systems:
Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
For demonstration purposes only, the installation process for R-2.11.1.pkg on Mac OS X 10.5 and higher is shown here. The exact installation process will differ between operating systems and versions. Therefore, it is likely that your installation process will differ from the one shown here, although it may also bear some similarities. The process goes as follows:
Locate and double-click the R-2.11.1 package file that you downloaded earlier.
The Install R 2.11.1 wizard will open in a new window. From this Introduction page, click on the Continue button.
The wizard will advance to the Read Me page. Click on the Continue button.
The wizard will advance to the License page. Click on the Continue button.
A window will pop up asking you to agree to the license terms. Click on the Agree button.
The wizard will advance to the Destination Select page. Change the installation location, only if you have an explicit reason to do so. Otherwise, click on the Install button.
The wizard will advance to the Installation page. It will automatically install the necessary files on your computer. This process will take approximately five minutes.
Once the installation is complete, the wizard will advance to the Summary page. Here, you will receive a message indicating that R was installed successfully. Click on the Close button to exit the wizard.
You can launch R at any time by browsing to its location on your hard drive and double-clicking on its icon.
After completing the installation process, double-click the R icon to launch the R console.
What just happened?
You just finished installing R and launched it for the first time. Next, we will learn how to use R by issuing our first command.