Installing R and RStudio

To get started with R, you demand to learn your own re-create. This appendix volition prove you how to download R as well as RStudio, a software application that makes R easier to utilise. Y'all'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 available through the web page 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 system: Windows, Mac, or Linux.

Windows

To install R on Windows, click the "Download R for Windows" link. So click the "base of operations" link. Side by side, 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 3.0.3 volition be replaced by the most current version of R. The link downloads an installer program, which installs the nearly upwards-to-date version of R for Windows. Run this program and step through the installation wizard that appears. The wizard will install R into your programme files folders and place a shortcut in your Start menu. Note that you'll need to accept 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-three.0.three package link (or the bundle link for the well-nigh 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, merely the defaults will be suitable for most users. I've never constitute a reason to change them. If your estimator requires a countersign earlier installing new progams, yous'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 can build R from source on these platforms, the process is much more than complicated and won't provide much do good for virtually users. For Linux systems, the contrary is true. Precompiled binaries can be plant for some systems, just it is much more common to build R from source files when installing on Linux. The download pages on CRAN's website provide information about building 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 appointment. 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 lot wish to install on. The verbal installation process will vary depending on the Linux system you employ. 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-flake

R comes in both 32-bit and 64-bit versions. Which should you employ? In most cases, information technology 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 retentiveness. 64-bit R uses 64-fleck retentiveness pointers, and 32-bit R uses 32-scrap memory pointers. This ways 64-flake R has a larger memory infinite to utilize (and search through).

Equally a dominion of pollex, 32-chip builds of R are faster than 64-fleck builds, though not e'er. On the other hand, 64-bit builds tin can handle larger files and information sets with fewer memory management problems. In either version, the maximum allowable vector size tops out at around 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 organisation supports 64-scrap R.

Using R

R isn't a program that you can open and first using, like Microsoft Word or Internet Explorer. Instead, R is a computer language, like C, C++, or UNIX. You lot employ R by writing commands in the R language and asking your computer to interpret them. In the erstwhile days, people ran R code in a UNIX terminal window—as if they were hackers in a picture show from the 1980s. At present almost everyone uses R with an awarding called RStudio, and I recommend that you do, likewise.

R and UNIX

Yous can still run R in a UNIX or Fustigate window past typing the command:

              R            

which opens an R interpreter. Yous tin then do your piece of work and close the interpreter by running q() when you are finished.

RStudio

RStudio is an application like Microsoft Discussion—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 same for Windows, Mac Os, and Linux. That volition help me friction match the volume to your personal experience.

You can download RStudio for free. Just click the "Download RStudio" push and follow the simple instructions that follow. Once you've installed RStudio, y'all 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 unremarkably do not program from a terminal window, then the Windows and Mac downloads for R come with a simple program that opens a concluding-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 do a niggling more than the basic terminal window, just not much. Yous may hear people refer to them every bit the Windows or Mac R GUIs.

When you open RStudio, a window appears with three panes in information technology, as in Effigy A.1. The largest pane is a console window. This is where you'll run your R code and run into 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 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. You'll learn about these panes as they become useful throughout the course of this book.

The RStudio IDE for R.

Figure A.ane: The RStudio IDE for R.

Do I nevertheless need to download R?

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

Opening R

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