Chapter 2. Preparing R for Battle

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:

  1. Browse to the official R website at http://www.r-project.org; the home page looks like the following:
    Time for action - downloading and installing R
  2. Under the Download, Packages heading on the left-hand side of the screen, click on the CRAN link.
    Time for action - downloading and installing R
  3. 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.
    Time for action - downloading and installing R
  4. 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).
    Time for action - downloading and installing R
  5. 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.

    Time for action - downloading and installing R
  6. 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:

Macintosh: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Macintosh_0029

Unix-based: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Unix_002dlike_0029

Windows: http://cran.r-project.org/doc/FAQ/R-FAQ.html#How-can-R-be-installed-_0028Windows_0029

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:

  1. Locate and double-click the R-2.11.1 package file that you downloaded earlier.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  2. The Install R 2.11.1 wizard will open in a new window. From this Introduction page, click on the Continue button.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  3. The wizard will advance to the Read Me page. Click on the Continue button.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  4. The wizard will advance to the License page. Click on the Continue button.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  5. A window will pop up asking you to agree to the license terms. Click on the Agree button.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  6. 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.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  7. 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.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  8. 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.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  9. You can launch R at any time by browsing to its location on your hard drive and double-clicking on its icon.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration
  10. After completing the installation process, double-click the R icon to launch the R console.
    Example: R 2.11.1 Mac OS X 10.5+ installation wizard demonstration

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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.21.190