Installing R and RStudio

To get started with R, you need to learn your own copy. This appendix will show you how to download R as well as RStudio, a software application that makes R easier to utilize. You'll go from downloading R to opening your first R session.

Both R and RStudio are gratuitous and piece of cake to download.

How to Download and Install R

R is maintained by an international team of developers who brand the language available through the web folio of The Comprehensive R Archive Network. The top of the web page provides three links for downloading R. Follow the link that describes your operating arrangement: Windows, Mac, or Linux.

Windows

To install R on Windows, click the "Download R for Windows" link. Then click the "base" link. Adjacent, click the outset link at the peak of the new page. This link should say something like "Download R 3.0.iii for Windows," except the iii.0.3 will be replaced past the most current version of R. The link downloads an installer program, which installs the virtually upward-to-date version of R for Windows. Run this program and footstep through the installation wizard that appears. The wizard volition install R into your programme files folders and identify a shortcut in your Get-go menu. Annotation that you'll demand to have all of the appropriate assistants privileges to install new software on your machine.

Mac

To install R on a Mac, click the "Download R for Mac" link. Next, click on the R-3.0.three package link (or the package link for the virtually electric current release of R). An installer will download to guide you through the installation process, which is very easy. The installer lets you lot customize your installation, but the defaults will be suitable for virtually users. I've never found a reason to modify them. If your computer requires a password earlier installing new progams, you'll need it here.

Binaries Versus Source

R can be installed from precompiled binaries or built from source on whatsoever operating system. For Windows and Mac machines, installing R from binaries is extremely easy. The binary comes preloaded in its own installer. Although you tin build R from source on these platforms, the process is much more complicated and won't provide much do good for well-nigh users. For Linux systems, the opposite is truthful. Precompiled binaries tin can be found for some systems, merely it is much more common to build R from source files when installing on Linux. The download pages on CRAN'due south website provide information about building R from source for the Windows, Mac, and Linux platforms.

Linux

R comes preinstalled on many Linux systems, but you'll want the newest version of R if yours is out of date. The CRAN website provides files to build R from source on Debian, Redhat, SUSE, and Ubuntu systems under the link "Download R for Linux." Click the link and and then follow the directory trail to the version of Linux you wish to install on. The verbal installation process volition vary depending on the Linux organisation you utilise. CRAN guides the process by group each set of source files with documentation or README files that explain how to install on your system.

32-flake Versus 64-bit

R comes in both 32-bit and 64-flake versions. Which should you apply? In about cases, it won't affair. Both versions use 32-bit integers, which ways they compute numbers to the same numerical precision. The divergence occurs in the way each version manages memory. 64-flake R uses 64-bit memory pointers, and 32-bit R uses 32-bit memory pointers. This ways 64-fleck R has a larger memory space to use (and search through).

As a rule of thumb, 32-bit builds of R are faster than 64-flake builds, though not e'er. On the other hand, 64-bit builds tin can handle larger files and data sets with fewer memory management problems. In either version, the maximum allowable vector size tops out at around 2 billion elements. If your operating system doesn't support 64-bit programs, or your RAM is less than four GB, 32-bit R is for y'all. The Windows and Mac installers will automatically install both versions if your system supports 64-bit R.

Using R

R isn't a plan that you tin can open and start using, like Microsoft Word or Net Explorer. Instead, R is a computer language, like C, C++, or UNIX. You utilise R past writing commands in the R language and asking your computer to interpret them. In the old days, people ran R code in a UNIX terminal window—as if they were hackers in a moving picture from the 1980s. Now almost everyone uses R with an application chosen RStudio, and I recommend that yous do, too.

R and UNIX

You can still run R in a UNIX or Fustigate window by typing the command:

              R            

which opens an R interpreter. You can so practice your work and close the interpreter by running q() when you are finished.

RStudio

RStudio is an application similar Microsoft Discussion—except that instead of helping yous write in English language, RStudio helps y'all write in R. I use RStudio throughout the volume considering it makes using R much easier. Also, the RStudio interface looks the same for Windows, Mac OS, and Linux. That will aid me friction match the book to your personal experience.

You can download RStudio for free. Only click the "Download RStudio" button and follow the simple instructions that follow. Once you've installed RStudio, you can open it similar any other program on your computer—ordinarily by clicking an icon on your desktop.

The R GUIs

Windows and Mac users usually exercise not program from a terminal window, so the Windows and Mac downloads for R come with a simple program that opens a concluding-like window for you to run R lawmaking in. This is what opens when you lot click the R icon on your Windows or Mac computer. These programs do a lilliputian more the basic terminal window, simply non much. You may hear people refer to them as the Windows or Mac R GUIs.

When yous open RStudio, a window appears with three panes in it, equally in Effigy A.1. The largest pane is a panel window. This is where yous'll run your R code and see results. The panel window is exactly what yous'd encounter if you lot ran R from a UNIX console or the Windows or Mac GUIs. Everything else you see is unique to RStudio. Hidden in the other panes are a text editor, a graphics window, a debugger, a file manager, and much more. Y'all'll learn almost these panes equally they become useful throughout the grade of this book.

The RStudio IDE for R.

Figure A.1: The RStudio IDE for R.

Do I still demand to download R?

Fifty-fifty if yous apply RStudio, you'll nevertheless need to download R to your calculator. RStudio helps y'all utilise the version of R that lives on your computer, but information technology doesn't come with a version of R on its ain.

Opening R

Now that yous have both R and RStudio on your calculator, you can begin using R by opening the RStudio program. Open RStudio just as you lot would any plan, by clicking on its icon or past typing "RStudio" at the Windows Run prompt.