Section 4.2 Installing and Running R
Let’s get started. Obviously you will need a computer. If you are working on a tablet device or smartphone, you may want to skip forward to the chapter on R-Studio, because regular old R has not yet been reconfigured to work on tablet devices (but there is a workaround for this that uses R-studio). There are a few experiments with web-based interfaces to R, like this one - http://dssm.unipa.it/R-php/R-php-1/R/ - but they are still in a very early stage. If your computer has the Windows(r), Mac-OS-X(r) or a Linux operating system, there is a version of R waiting for you at http://cran.r-project.org/. Download and install your own copy. If you sometimes have difficulties with installing new software and you need some help, there is a wonderful little book by Thomas P. Hogan called, Bare Bones R: A Brief Introductory Guide that you might want to buy or borrow from your library. There are lots of sites online that also give help with installing R, although many of them are not oriented towards the inexperienced user. I searched online using the term “help installing R” and I got a few good hits. One site that was quite informative for installing R on Windows was at “readthedocs.org”, and you can try to access it at this TinyUrl: http://tinyurl.com/872ngtt. For Mac users there is a video by Jeremy Taylor at Vimeo.com, http://vimeo.com/36697971, that outlines both the initial installation on a Mac and a number of other optional steps for getting started. YouTube also had four videos that provide brief tutorials for installing R. Try search for “install R” in the YouTube search box.
![A screenshot of the R Console application on a Mac. The console has a bright orange background. Near the bottom, a greater-than symbol serves as the command prompt. The user has typed 1+1 and R has responded with [1] 2.](external/r-console-mac.png)
1+1.The rest of this chapter assumes that you have installed R and can run it on your computer as shown in the screenshot on this page. (Note that this screenshot is from the Mac version of R: if you are running Windows or Linux your R screen may appear slightly different from this.) Just for fun, one of the first things you can do when you have R running is to click on the color wheel and customize the appearance of R. This screen shot uses Syracuse orange as a background color. The screenshot also shows a simple command to type that shows the most basic method of interaction with R. Notice near the bottom of the screenshot a greater than (
>) symbol. This is the command prompt: When R is running and it is the active application on your desktop, if you type a command it appears after the > symbol. If you press the “enter” or “return” key, the command is sent to R for processing. When the processing is done, a result may appear just under the >. When R is done processing, another command prompt (>) appears and R is ready for your next command.
In the screen shot, the user has typed
1+1 and pressed the enter key. The formula 1+1 is used by elementary school students everywhere to insult each other’s math skills, but R dutifully reports the result as 2. If you are a careful observer, you will notice that just before the 2 there is a 1 in brackets, like this: [1]. That [1] is a line number that helps to keep track of the results that R displays. Pretty pointless when only showing one line of results, but R likes to be consistent, so we will see quite a lot of those numbers in brackets as we dig deeper.
