Installing R and RStudio

To get started with R, you lot demand to larn your ain copy. This appendix will show you how to download R as well as RStudio, a software application that makes R easier to use. You lot'll become from downloading R to opening your starting time R session.

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

How to Download and Install R

R is maintained past an international squad of developers who make the language bachelor 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. And so click the "base of operations" link. Next, click the kickoff link at the top of the new page. This link should say something like "Download R 3.0.3 for Windows," except the three.0.iii will be replaced past the near current version of R. The link downloads an installer program, which installs the nearly up-to-engagement version of R for Windows. Run this programme and step through the installation magician that appears. The wizard volition install R into your program files folders and place a shortcut in your Start menu. Note that you'll demand to have all of the appropriate administration privileges to install new software on your motorcar.

Mac

To install R on a Mac, click the "Download R for Mac" link. Adjacent, click on the R-three.0.3 package link (or the parcel link for the about current release of R). An installer volition download to guide you through the installation process, which is very easy. The installer lets you customize your installation, only the defaults will be suitable for most users. I've never constitute a reason to change them. If your computer requires a password before installing new progams, yous'll need it hither.

Binaries Versus Source

R can be installed from precompiled binaries or congenital from source on any operating system. For Windows and Mac machines, installing R from binaries is extremely piece of cake. 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 benefit for most users. For Linux systems, the opposite is true. 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's 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 so follow the directory trail to the version of Linux you wish to install on. The verbal installation process will vary depending on the Linux system you utilise. CRAN guides the process by grouping each set of source files with documentation or README files that explain how to install on your organisation.

32-bit Versus 64-bit

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

Equally a rule of thumb, 32-bit builds of R are faster than 64-bit builds, though not always. On the other paw, 64-flake builds tin handle larger files and information sets with fewer retentivity management problems. In either version, the maximum allowable vector size tops out at around two billion elements. If your operating system 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 will automatically install both versions if your organization supports 64-flake R.

Using R

R isn't a plan that you tin can open and kickoff using, similar Microsoft Word or Cyberspace Explorer. Instead, R is a computer language, similar C, C++, or UNIX. Yous utilise R by writing commands in the R language and asking your computer to translate them. In the old days, people ran R code in a UNIX final window—equally if they were hackers in a movie from the 1980s. At present almost anybody uses R with an application chosen RStudio, and I recommend that you practice, too.

R and UNIX

You lot tin all the same run R in a UNIX or Bash window past typing the command:

              R            

which opens an R interpreter. Y'all 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 it makes using R much easier. Too, the RStudio interface looks the same for Windows, Mac OS, and Linux. That will assistance me match the book to your personal feel.

You lot tin can download RStudio for gratuitous. Just click the "Download RStudio" button and follow the simple instructions that follow. Once you've installed RStudio, yous tin open it similar any other program on your computer—usually past 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 simple program that opens a terminal-like window for y'all to run R code in. This is what opens when yous click the R icon on your Windows or Mac computer. These programs do a piddling more than the basic last window, but not much. You may hear people refer to them equally the Windows or Mac R GUIs.

When y'all 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 console window is exactly what you lot'd see if you ran R from a UNIX console or the Windows or Mac GUIs. Everything else yous 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 than. Y'all'll learn virtually 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 still need to download R?

Even if y'all use RStudio, you lot'll even so need to download R to your estimator. RStudio helps you employ the version of R that lives on your reckoner, but it doesn't come up with a version of R on its own.

Opening R

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