3  Setting up your computer

3.1 Goals

In this lesson you will start using the computer tools introduced in the previous lesson.

3.2 Introduction

The statistical software R and RStudio and version control software git will be used in this course. No prior experience with R, RStudio or git is assumed. We’ll take class time to learn the software.

In this lesson you will

  • install the software on your computer,
  • learn to use the software “in the cloud”,
  • create a github account, and
  • complete a task to let me know this is done or ask for help and tell me your github account name.

The steps below are written for Windows and Macintosh computers, with necessary variations noted. If you use a Chromebook, you can’t install this software, so skip ahead to the rstudio.cloud section. If you use linux, adapt the instructions below to install the software and contact me if you have trouble.

3.3 R

  • To download and install R go to r-project.org and click on the link to download R. For Mac, you want “R-4.2.1.pkg” (or a more recent version). For Windows, follow the link marked “base”. If you already have R installed, please check to be sure you have version 4.0 or later, and update the software if you have an older version. You can see the version of R with the command R.version.

3.4 Rstudio

  • To download and install Rstudio, go to Rstudio.com and click on the download link to download Rstudio. You want the free Rstudio Desktop for your computer (Windows, Mac, Linux).

3.5 Git

  • To download and install git:
    • on Windows, go to git-scm.org and click on the link to download a version for Windows
    • on Macintosh, use the Terminal app or the Terminal tab in Rstudio and type xcode-select --install to download and install git. There should be two minus signs in front of “install”; some web browsers may display this incorrectly as a dash (one symbol).

3.6 rstudio.cloud

If you have a Chromebook you can use R, Rstudio and git through the cloud service rstudio.cloud. Everyone should learn to use the cloud service as a backup in case of problems with the software on their own computer.

3.7 Dalhousie on-campus labs

R and Rstudio are available on Dalhousie computer labs, but the git version control software must be installed following the instructions for Windows computers above. Since all your user files are erased from lab computers when you log out, this process must be repeated on each login. For this reason, I don’t recommend using lab computers for this course, unless you are using the rstudio.cloud service.

3.8 Packages

You are not done downloading and installing software yet! Most of the tools we will use with R are distributed as add-on packages. These are bundles of software that add new functions to R. There are three steps to use a pacakge:

  • Install the package (done only once)
  • Tell R you will be using the package (done each time you start R)
  • Learn how to use the package (a major goal of this course)

I install new packages all the time on my machine. Right now I have 203 installed. It’s also common to update to new versions. Rstudio trys to help you identify packages you need to install – we’ll see how later on. An optional task for today is to install packages suggested by Healy in his Preface. (We’ll use lots more packages than this, but this is a good start.) Cut and paste the following R code into the window marked “Console” in Rstudio.

my_packages <- c("tidyverse", "broom", "coefplot", "cowplot",
                 "gapminder", "GGally", "ggrepel", "ggridges", "gridExtra",
                 "here", "interplot", "margins", "maps", "mapproj",
                 "mapdata", "MASS", "quantreg", "rlang", "scales",
                 "survey", "srvyr", "viridis", "viridisLite", 
                 "socviz", "devtools", "patchwork", "usethis", "gitcreds",
                 "remotes", "paletteer", "ggthemes", "ggtext")

install.packages(my_packages)

3.9 Github

Github is a web service for sharing and publishing github repositories and many related services. We will learn more about using the service in later lessons.

3.10 Exercises

The task today is especially important. Get all these tools working on your computer by installing them or using rstudio.cloud before the next lesson.