Installing R and RStudio

To get started with R, you need to larn your ain copy. This appendix will testify y'all how to download R as well equally RStudio, a software application that makes R easier to utilise. Y'all'll become from downloading R to opening your outset 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 linguistic communication available through the web page of The Comprehensive R Archive Network. The top of the web folio provides three links for downloading R. Follow the link that describes your operating organisation: Windows, Mac, or Linux.

Windows

To install R on Windows, click the "Download R for Windows" link. And then click the "base of operations" link. Adjacent, click the get-go link at the meridian of the new folio. This link should say something like "Download R three.0.3 for Windows," except the three.0.3 volition be replaced by the most electric current version of R. The link downloads an installer programme, which installs the nigh upwards-to-engagement version of R for Windows. Run this plan and step through the installation magician that appears. The wizard volition install R into your program files folders and identify a shortcut in your Start menu. Note that you'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-iii.0.iii bundle link (or the package link for the almost 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 volition be suitable for most users. I've never found a reason to change them. If your computer requires a password before installing new progams, you'll demand it here.

Binaries Versus Source

R can be installed from precompiled binaries or built from source on any operating system. For Windows and Mac machines, installing R from binaries is extremely easy. The binary comes preloaded in its ain installer. Although you can build R from source on these platforms, the process is much more complicated and won't provide much do good for most users. For Linux systems, the opposite is truthful. Precompiled binaries can be found for some systems, but it is much more mutual to build R from source files when installing on Linux. The download pages on CRAN'south website provide information about edifice 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 then follow the directory trail to the version of Linux you wish to install on. The exact installation procedure will vary depending on the Linux organization you use. CRAN guides the process by grouping each ready of source files with documentation or README files that explain how to install on your system.

32-bit Versus 64-scrap

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

As a dominion of thumb, 32-flake builds of R are faster than 64-bit builds, though not always. On the other hand, 64-fleck builds can handle larger files and information sets with fewer memory management bug. In either version, the maximum allowable vector size tops out at around 2 billion elements. If your operating system doesn't back up 64-bit programs, or your RAM is less than 4 GB, 32-fleck R is for yous. The Windows and Mac installers will automatically install both versions if your system supports 64-scrap R.

Using R

R isn't a plan that you tin can open and start using, like Microsoft Word or Internet Explorer. Instead, R is a computer language, like C, C++, or UNIX. Y'all use R past writing commands in the R linguistic communication and asking your computer to interpret them. In the sometime days, people ran R code in a UNIX terminal window—equally if they were hackers in a movie from the 1980s. Now near everyone uses R with an application chosen RStudio, and I recommend that you lot practise, too.

R and UNIX

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

              R            

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

RStudio

RStudio is an application like Microsoft Word—except that instead of helping you write in English, RStudio helps you write in R. I use RStudio throughout the book because information technology makes using R much easier. Also, the RStudio interface looks the aforementioned for Windows, Mac Os, and Linux. That volition help me match the book to your personal feel.

You lot can download RStudio for free. Just click the "Download RStudio" button and follow the uncomplicated instructions that follow. Once yous've installed RStudio, yous can open information technology like any other program on your computer—commonly by clicking an icon on your desktop.

The R GUIs

Windows and Mac users usually do not programme from a terminal window, so the Windows and Mac downloads for R come with a elementary plan that opens a terminal-like window for you to run R lawmaking in. This is what opens when yous click the R icon on your Windows or Mac computer. These programs exercise a picayune more than the basic terminal window, only not much. You may hear people refer to them as the Windows or Mac R GUIs.

When you lot open RStudio, a window appears with three panes in it, as in Figure A.i. The largest pane is a console window. This is where yous'll run your R code and see results. The console window is exactly what you'd run into if yous ran R from a UNIX console or the Windows or Mac GUIs. Everything else you run into is unique to RStudio. Hidden in the other panes are a text editor, a graphics window, a debugger, a file director, and much more. Yous'll learn well-nigh these panes every bit they become useful throughout the course of this volume.

The RStudio IDE for R.

Figure A.1: The RStudio IDE for R.

Practice I notwithstanding need to download R?

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

Opening R

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