Skip to main content

BSCI 1511L Statistics Manual: 6 Installing R and RStudio

Introduction to Biological Sciences lab, second semester

What is R?

R is a freely-available, open-source programming language that is widely used for statistics and data visualization.  It is available for PC, Mac, and Linux.  Although R itself is a programming language, there are collections of pre-programmed functions, code, and data sets called packages that can be called on by users.  R can be run from the command line, but it is often used through an integrated development environment (IDE) called RStudio.  RStudio makes it easy to run R commands, create scripts, and check on the values of variables. 

There are many R packages available to do common statistical tests and graphing tasks.  Several packages are shipped with R itself and others can be downloaded and installed from online libraries.  In this class, we will not learn to program in R, but will learn how to install R and RStudio, and use existing packages to do several types of statistical analyses.

How do I acquire R ?

R can be downloaded from one of many Comprehensive R Archive Network (CRAN) sites.  The closest one to Vanderbilt is at UT Knoxville: - http://mirrors.nics.utk.edu/cran/ .  From the UTK CRAN site homepage, click on the "Download R for [OS]" link that is appropriate for your operating system. 

Downloading and installing R and RStudio for Windows

Downloading and installing R

On the CRAN Windows download page, click on the "base" link, which will take you to the download page for the most recent base R distribution.  Then click on the "Download R X.X.X for Windows" link (where X.X.X is the version number).  This will initiate the download of an executable installation file to the default download directory for your browser.  After the download completes, click (or double-click) on the installer file to initiate the install.  Click the Next button repeatedly to accept all of the defaults.  After completing the install, you should see an R shortcut on your desktop.  Double-click on the icon to launch R.  You should see the R Console with a ">" prompt at the bottom.  Enter:

2+2

and you should see

[1] 4

as the answer.  Click the X in the upper right of the window to quit the console, and don't save.

 

Downloading and installing RStudio

Go to https://www.rstudio.com/products/rstudio/download/ and click on the installer link for Windows.  This will initiate the download of an executable installation file to the default download directory for your browser.  After the download completes, click (or double-click) on the installer file to initiate the install. Click the Next button repeatedly to accept all of the defaults.  By default, there is no shortcut on the desktop - if you want one there, click on the Start menu, find the RStudio icon in the list of programs and drag it to the desktop.  Run RStudio.  In the left side of the window, you should see a Console pane similar to what you saw before.  Try adding 2+2 as you did above and you should get the same result. 

Downloading and installing R and RStudio for Mac OS X

Downloading and installing R

The main CRAN download page for Mac contains the installers for OS X 10.6 and above.  For older operating systems, read the page and rummage around until you find what you need.  On the main download page, click on the link for the correct binary for your OS version.  When the download is complete, click on the installer file to launch the install.  Click the Next button repeatedly to accept all of the defaults, and Agree to the terms.  Click on Install as prompted and enter your password as necessary.  When complete, close the installation window. 

In Finder, click on Applications.  You should see R listed.  Double click on it to launch R. You should see the R Console with a ">" prompt at the bottom.  Enter:

2+2

and you should see

[1] 4

as the answer.  Click the red dot in the upper left of the window to quit the console, and don't save.

 

Downloading and installing RStudio

Go to https://www.rstudio.com/products/rstudio/download/ and click on the appropriate installer link for your computer's operating system.  This will initiate the download of an executable installation file to the default download directory for your browser.  After the download completes, click on the .dmg file to open it. Drag the RStudio icon into the Applications folder and close the window.  You should now be able to find RStudio in your Applications folder.  Run RStudio.  Allow the application to run.  In the left side of the window, you should see a Console pane similar to what you saw before.  Try adding 2+2 as you did above and you should get the same result.