R

Scroll down for:

  • R installation instructions for PC’s and Macs.
  • Links to running R online. Nothing to download or install.

3 and 1/2 minute video introduction to using R

In the above video I show you how to:

  • use R to do basic arithmetic
  • to calculate the average of the data x =  1, 5, 8, 6
  • how to use the R console like a calculator
  • how to work with and save R scripts

Here is the R script from the above video:

 #R script to calculate mean of x
x = c(1, 5, 8, 6)
mean(x) 

You can copy and paste the above into R. Don’t copy the line numbers 1, 2, 3 though!

Note here is how to calculate the average (or mean) of $x$ without using R:

$$ \bar{x} =  \dfrac{\sum x}{n} = \dfrac{1 + 5 + 8 + 6}{4} = 5 $$

About R

In the real world, almost all statistical calculations are done on computers. In this course we will be using the program called R.

  • R is powerful.
    It is a state-of-the-art statistical computing environment used by statisticians, scientists, and businesses all over the world. It is one of the most commonly used environments for statistical analyses.
  • R is FREE and easy to install
  • R is extremely easy to get started with
  • It is easy to find answers to any question you might have about R by doing a Google search.

The R homepage is https://www.r-project.org/

Download
and
Installation Instructions for R

R can only be installed on PC’s, Macs, and Unix (Linux) computers.
You can’t install R on your cell phone, Android tablet, iPad, or Chromebook.

  1. Go to the R download page: https://cloud.r-project.org/
  2. In the R download page click on the appropriate download link for your OS.
  3. Installation Instructions for Windows PC users.
    If you click on the R for Windows (because you have a PC) you will get a page that looks like:

    Click on the “base” option.  You will get a page that looks like:

    Click on Download R… and download and install R. It is easy.To run a line in an R script on a PC put your cursor in the line you want to run then click Ctrl R.   If you want to run the entire script, click Ctrl A and then Ctrl R.
  4. Installation Instructions for Mac users.
    If you click on R for Mac you end up at a page that has the following download links on it:

    You should install XQuartz first (if it is not already installed on your Mac). Reboot your Mac. Then install R.To run a line in an R script on a Mac do the following:
    Highlight the line, then  command-enter.

 

How to use R online.
Nothing to download or install.

Online R Compilers

You can also compile (run) R online, for free, using your web browser, at the following sites:

The above sites were last checked March 2022. It they don’t work, you can find other free online R compilers by doing a Google search.

Warning. The above sites are not designed for processing data files. For that, you need to install R on your own computer (which is the best way to experience R).  However, the above sites do allow you to use R from your tablet or cell phone.

Online Compilers that no longer seem to work.

  • https://rdrr.io/snippets/

Useful Links on using R