BMR 617: Statistical Techniques for the Biomedical Sciences

Installing R

Introduction: understanding what we'll install

R is a statistical computing environment. In it's most basic form, it runs as a command-line tool. This means you can open up a terminal (a text-only interface to your computer's operating system) and interact with R by typing commands and seeing the result. We'll actually do this, just once, to make sure R is installed properly.

While command-line tools are actually very powerful, they are not a very user-friendly way to use software. So as well as installing R, we'll also install a program called RStudio, which is an Integrated Development Environment (IDE). This provides a more user-friendly approach to using the underlying R environment. Note you'll still need to type commands and see the results, but we'll have a better environment to do that in

Installing R

Testing the R installation.

Installing RStudio

Using the console on its own is not very user friendly. Here, we'll install RStudio, which will make things easier going forward. Note we'll still be typing commands, but RStudio will give us lots of useful functionality for managing those commands.

Installing Packages

R supports the idea of packages, which are libraries of code designed to provide functionality beyond the base functionality of R. There are thousands of R libraries that have been written for many different fields of scientific research and data analysis.

To use a package, it must

We will install a package called tidyverse, which we'll use regularly throughout the course.

To test the installation, try to load the library. You can do this by typing


library(tidyverse)
        
in the console.

If it's successful, you should see output looking like


── Attaching packages ────────────────────────────────────────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.3.6     ✔ purrr   0.3.4
✔ tibble  3.1.8     ✔ dplyr   1.0.9
✔ tidyr   1.2.0     ✔ stringr 1.4.0
✔ readr   2.1.2     ✔ forcats 0.5.1
── Conflicts ───────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
        

If you've made it this far, you've successfully installed R and RStudio, done some very simple statistics with R, and created your first simple plot, as well as installing an R package. Next time, we'll learn a little bit more about how R works and start to explore some data.