Installing R and RStudio

To become started with R, you need to learn your own copy. This appendix will show you how to download R as well equally RStudio, a software application that makes R easier to apply. You'll get from downloading R to opening your showtime 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 squad of developers who make the linguistic communication available through the web page of The Comprehensive R Archive Network. The peak of the web folio provides three links for downloading R. Follow the link that describes your operating system: Windows, Mac, or Linux.

Windows

To install R on Windows, click the "Download R for Windows" link. Then click the "base of operations" link. Next, click the first link at the top of the new page. This link should say something like "Download R 3.0.three for Windows," except the iii.0.3 volition be replaced by the most electric current version of R. The link downloads an installer program, which installs the most up-to-date version of R for Windows. Run this program and stride through the installation wizard that appears. The wizard will install R into your program files folders and identify a shortcut in your Start carte du jour. Notation that you'll need 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. Adjacent, click on the R-3.0.3 bundle link (or the packet link for the most current release of R). An installer will download to guide you through the installation process, which is very easy. The installer lets you customize your installation, but the defaults will be suitable for nigh users. I've never found a reason to change them. If your reckoner requires a password before installing new progams, you'll need information technology 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 lot can build R from source on these platforms, the procedure is much more than complicated and won't provide much do good for most users. For Linux systems, the opposite is true. Precompiled binaries can be establish for some systems, only it is much more common to build R from source files when installing on Linux. The download pages on CRAN's website provide information near building R from source for the Windows, Mac, and Linux platforms.

Linux

R comes preinstalled on many Linux systems, but you'll desire the newest version of R if yours is out of engagement. 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 then follow the directory trail to the version of Linux you wish to install on. The exact installation process volition vary depending on the Linux system you use. CRAN guides the process by grouping each set of source files with documentation or README files that explain how to install on your system.

32-bit Versus 64-flake

R comes in both 32-scrap and 64-scrap versions. Which should you use? In most cases, it won't matter. Both versions apply 32-bit integers, which means they compute numbers to the same numerical precision. The divergence occurs in the fashion each version manages memory. 64-bit R uses 64-scrap memory pointers, and 32-bit R uses 32-scrap memory pointers. This means 64-bit R has a larger retentivity infinite to employ (and search through).

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

Using R

R isn't a program that you can open and start using, like Microsoft Word or Net Explorer. Instead, R is a estimator language, like C, C++, or UNIX. You use R by writing commands in the R language and request your estimator to translate them. In the former days, people ran R code in a UNIX terminal window—as if they were hackers in a movie from the 1980s. Now almost everyone uses R with an application chosen RStudio, and I recommend that you do, too.

R and UNIX

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

              R            

which opens an R interpreter. Yous can then practise your piece of work and close the interpreter past running q() when yous are finished.

RStudio

RStudio is an application like Microsoft Give-and-take—except that instead of helping you write in English, RStudio helps you write in R. I use RStudio throughout the book because it makes using R much easier. Also, the RStudio interface looks the aforementioned for Windows, Mac OS, and Linux. That will help me match the volume to your personal feel.

You can download RStudio for gratis. Just click the "Download RStudio" push and follow the simple instructions that follow. In one case you've installed RStudio, you tin open up information technology like any other program on your computer—usually by clicking an icon on your desktop.

The R GUIs

Windows and Mac users normally do non program from a terminal window, and so the Windows and Mac downloads for R come with a simple program that opens a terminal-like window for you to run R code in. This is what opens when you click the R icon on your Windows or Mac computer. These programs exercise a little more than the basic final window, merely non much. You lot may hear people refer to them equally the Windows or Mac R GUIs.

When you open RStudio, a window appears with three panes in information technology, as in Figure A.1. The largest pane is a console window. This is where you'll run your R code and see results. The panel window is exactly what you'd see if you ran R from a UNIX console or the Windows or Mac GUIs. Everything else yous meet is unique to RStudio. Hidden in the other panes are a text editor, a graphics window, a debugger, a file director, and much more. You'll learn about these panes equally they go useful throughout the class of this book.

The RStudio IDE for R.

Figure A.i: The RStudio IDE for R.

Do I still need to download R?

Even if you use RStudio, you lot'll still need to download R to your computer. RStudio helps you lot employ the version of R that lives on your computer, but it doesn't come with a version of R on its ain.

Opening R

Now that you accept both R and RStudio on your computer, you can begin using R past opening the RStudio program. Open RStudio but as you would any program, by clicking on its icon or by typing "RStudio" at the Windows Run prompt.