Downloading and Installing R and R Studio

R is a "programming environment" that allows you to perform a huge array of statistical (and non-statistical) tasks with very few commands. You can use it in at least two ways. You can cut and paste programs that I or others have written, make minor edits, and run the program. For this you don't really need to know anything about programming other than editing the program that is there. Alternatively, you can write extensive programs that will do just about anything you want. The nice thing is that even if you want to take the latter course, you will find that someone has been there before you. If you want to calculate confidence limits on a population proportion, you just download the code that someone else (Ken Kelley) has written, provide the necessary information, such as sample size and sample proportion, and click "run."

As I have said elsewhere, if you can download and install iTunes on your laptop, you can download and install R. I also strongly suggest that you also download a special editor named RStudio. It will make your work a great deal easier.

Let's start with RStudio. You can find a free copy at Just click on "Download now," and then select "Download RStudio Desktop." Then choose your operating system and click "Save File" when asked. When it has downloaded you simply have to open it to install it. That is it.

R is available for Windows, Macs, and Unix. I now have a Mac, so I will focus on that. However you should easily be able to adapt what I say to other environments. The R software is available at When you go to that site you will see something like:

On the left are links you might want to use in the future but can ignore for now. In the center top are the links for downloading what you want. Because I have an iMac, I would click on the Mac link. Mac users should note the line that says that you will also need XQuartx. Just click on that link and follow the instructions. PC users can ignore this issue. If you have a Mac, click on "R-3.3.0 pkg" (The number may change over time.)

If you have a PC, you will see the following menu. There is a button for "base", and that is what you want.

R for Windows

At this point Windows users will click on "base," which will give you (again with perhaps a different version number):

Click on the download button and, when asked, click on "Save File." It will take a while to download, but that's just because it is a huge set of files. It will probably have a revised version, so don't be concerned if it doesn't say exactly "R 3.3.0."

When downloading is complete, click on the file you just downloaded in that window and it will install R. You will probably be happy just to take the defaults. Don't worry about the scary messages from Windows asking if you really want to load this dangerous software. Just tell it to go ahead.

Running R

If you start up R, or RStudio, you will see a screen that looks very much like the following.

(I haven't the slightest idea why it says "Roasted Marshmellows" at the top, but you can't trust Unix geeks. It once said "Frisbee Sailing", and the most current version now says "Supposedly Educational".) The important thing for you is the ">" prompt below the text. This is where you can enter commands. For example, you could type x = c(3, 6, 5, 8, 9) or you could type xbar <- mean(x) and the variable "xbar" would be the mean. Just type "xbar" and the value of xbar will be printed. This works just fine, but I prefer to have my commands collected somewhere so that I can go back and immediately see what I have done. Or maybe I want to enter a bunch of commands and run them all at once. That is why I had you download RStudio.

If you start by opening RStudio, you will discover that it automatically opened R. The editor part of RStudio is in the upper left and the R console is in the lower left. Various things can appear on the right, depending on what you are doing. You would type your code, or paste the code that I give you, in the upper left. For example, to find the mean of 3, 6, 5, 8, & 9 you would have the following. (The symbol "<-" is just the way that R prefers to write "=" , although you may use an "=" if you prefer. Similarly, "#" indicates that what follows is just a comment.)

# Demonstration of finding the mean

x <- c(3, 6, 5, 8, 9)
xbar <- mean(x)

Put your cursor on the first line (or highlight all lines) and click the "run" button to execute each command. (Alternatively, you can type "Command/Enter" on a Mac or, I think, Ctrl-R on Windows.) You will end up with the following, where each command is echoed as it is run.

> x <- c(3,6,5,8,9)
> xbar <- mean(x)
> print(xbar)
[1] 6.2

Finally, let me say something about Rweb. Rweb is a small bit of code that I can enclose in a web page. It gives you a window in which you can write R code, or paste some of mine. You then click "Submit" and it will send the code off to someone's server, run R on it, and give you back the answer just as if you had been running R on your own computer. It's kind of neat. It has a few quirks, but it is better than starting an R session everytime you want to do some little thing. You can read about it at I rarely use it, but I should.