For this set of exercises as well as all following ones, we suggest that you write R scripts (one per set of exercises or a combined one for the whole course) and store them in the my_scripts folder contained in the course materials. This folder already contains a script stub called my_script.R which you can use for getting started.

1

To explore what R packages are out there that may be of interest for you, have a brief (!) look at the CRAN Task View section called SocialSciences and do a quick search for “regression” on METACRAN.
Although it may be tempting (there are so many interesting packages!), try not to spend more than 2 to 3 minutes on this (for now).

2

The first simple coding task for this exercise is to install a few packages from CRAN (we will use those later on in the course). Please install the following packages: remotes, dplyr, janitor, correlation (Note: We will need a few more packages throughout this course, but we do not have to install all of them now).
install.packages(c("remotes", "dplyr", "janitor", "correlation"))

3

Now, let’s load one of the packages you have just installed. Load the remotes package.
You do not need to enclose the package name in quotes when loading it.
library(remotes)

4

Some packages are not on CRAN. Another important source of R packages is GitHub (especially for development versions). So, let’s install a package from there. Install the emo package from GitHub. NB: To be able to install packages from GitHub on Windows machines, you will need to install Rtools first.
You can use a function from the remotes package for this. The required argument for the function for installing a package from GitHub needs to be in the form “user_name/repo_name” (i.e., the parts of the URL that come after github.com). If you need to install Rtools, make sure to select the version that is appropriate for your version of R.
library(remotes)

install_github("hadley/emo")

5

Check which packages are now installed on your system.
You can use the RStudio interface or a function for this.
installed.packages()

6

As a final exercise, add some comments to your script and save it (in the my_scripts folder).
Comments in R start with #. Ideally, these should explain what the code you have written does. You can simply save the R script file via the RStudio GUI.
# Check installed packages
installed.packages()