Installing R and RStudio

To become started with R, you need to acquire your own copy. This appendix will bear witness you how to download R besides every bit 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 free and easy to download.

How to Download and Install R

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

Windows

To install R on Windows, click the "Download R for Windows" link. And so click the "base" link. Next, click the first link at the peak of the new page. This link should say something like "Download R 3.0.3 for Windows," except the 3.0.three will be replaced by the nigh current version of R. The link downloads an installer plan, which installs the almost upwards-to-date version of R for Windows. Run this programme and step through the installation sorcerer that appears. The wizard volition install R into your program files folders and place a shortcut in your Start carte. Note that you lot'll need to have all of the appropriate administration privileges to install new software on your machine.

Mac

To install R on a Mac, click the "Download R for Mac" link. Side by side, click on the R-3.0.3 package link (or the parcel link for the most current release of R). An installer will download to guide you through the installation process, which is very piece of cake. The installer lets you customize your installation, merely the defaults will be suitable for most users. I've never found a reason to change them. If your computer requires a countersign earlier installing new progams, you'll demand it here.

Binaries Versus Source

R can be installed from precompiled binaries or built from source on whatsoever operating organisation. For Windows and Mac machines, installing R from binaries is extremely easy. The binary comes preloaded in its own installer. Although yous can build R from source on these platforms, the process is much more complicated and won't provide much benefit for most users. For Linux systems, the opposite is truthful. Precompiled binaries tin can be found for some systems, but it is much more common to build R from source files when installing on Linux. The download pages on CRAN's website provide information nigh edifice R from source for the Windows, Mac, and Linux platforms.

Linux

R comes preinstalled on many Linux systems, simply 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 nether the link "Download R for Linux." Click the link so follow the directory trail to the version of Linux you wish to install on. The exact installation procedure will vary depending on the Linux system you lot utilize. CRAN guides the process past group each set of source files with documentation or README files that explicate how to install on your system.

32-bit Versus 64-bit

R comes in both 32-fleck and 64-bit versions. Which should you utilize? In most cases, it won't matter. Both versions utilise 32-bit integers, which means they compute numbers to the same numerical precision. The difference occurs in the way each version manages memory. 64-chip R uses 64-fleck memory pointers, and 32-fleck R uses 32-flake memory pointers. This ways 64-bit R has a larger retentivity infinite to utilise (and search through).

As a rule of thumb, 32-bit builds of R are faster than 64-scrap builds, though non always. On the other hand, 64-fleck builds can handle larger files and information sets with fewer retentivity management issues. In either version, the maximum commanded 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 4 GB, 32-flake R is for you. The Windows and Mac installers will automatically install both versions if your system supports 64-flake R.

Using R

R isn't a program that you can open and kickoff using, like Microsoft Give-and-take or Internet Explorer. Instead, R is a computer language, like C, C++, or UNIX. You lot use R by writing commands in the R language and asking your figurer to translate them. In the old days, people ran R code in a UNIX concluding window—equally if they were hackers in a picture show from the 1980s. Now virtually everyone uses R with an application chosen RStudio, and I recommend that you do, as well.

R and UNIX

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

              R            

which opens an R interpreter. You can and then exercise your piece of work and shut the interpreter past running q() when you 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 employ RStudio throughout the book because it makes using R much easier. Also, the RStudio interface looks the same for Windows, Mac Os, and Linux. That volition help me match the book to your personal feel.

You can download RStudio for gratuitous. Just click the "Download RStudio" push and follow the unproblematic instructions that follow. Once you've installed RStudio, you can open it like any other program on your computer—usually by clicking an icon on your desktop.

The R GUIs

Windows and Mac users usually do not program from a last window, and so the Windows and Mac downloads for R come up with a simple program that opens a terminal-like window for y'all to run R code in. This is what opens when y'all click the R icon on your Windows or Mac figurer. These programs practise a little more than the bones terminal window, but not much. You may hear people refer to them as the Windows or Mac R GUIs.

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

The RStudio IDE for R.

Effigy A.1: The RStudio IDE for R.

Do I yet need to download R?

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

Opening R

Now that you have both R and RStudio on your calculator, y'all can begin using R past opening the RStudio program. Open up RStudio just as you would whatsoever program, by clicking on its icon or by typing "RStudio" at the Windows Run prompt.