Installing software

Before we start the course, we have to install two crucial pieces of software:

  • R: A free program for statistical programming
  • RStudio: An integrated development environment (IDE) which makes it easier to work with R.

Installing R

The latest version of R is available here.

  • Click the appropriate link for your operating system and follow the instructions for installing the latest stable release.
  • Depending on which OS you select, you may be given an option to install different components (e.g., base, contrib, Rtools).
    • For this course, you will only need the base package.

Installing RStudio

Download the Free Desktop version of RStudio from the download page of the Posit website.


Installing packages

To participate in this course, you will need to install several additional R packages. For example, we’ll make extensive use of the three packages described in the following table.

Package Description
lavaan A sophisticated and user-friendly package for structural equation modeling
dplyr A powerful suite of data-processing tools
ggplot2 A flexible and user-friendly package for making graphs

For the most part, you’ll install new packages when necessary as part of the weekly practical exercises. But, you might as well get a head start by installng lavaan, dplyr, and ggplot2 now. You don’t need any fancy tools to install new packages, we simply call the install.packages() function in R.

  1. Open RStudio
  2. Inside RStudio, find the window named Console on left side of the screen.
  3. Copy the following code into the console and hit Enter/Return to run the command.
install.packages(c("lavaan", "dplyr", "ggplot2"), dependencies = TRUE)

Compiling packages from source

On Windows and Mac, R packages are distributed in two ways:

  1. Pre-compiled binary executables
    • Binary packages can be run directly (equivalent to .exe files on Windows).
    • You don’t need any special tools to install binary packages.
  2. Archives of source code
    • Packages installed via source code must be compiled locally.
    • You will need an appropriate toolchain to build and install the package.
    • New versions of a package are usually distributed via source code before they get a binary release. So this option will get you the latest versions of the packages.

When you run the above command, you may see a message asking if you would like to compile certain packages from source. If so, it’s usually best to accept this option. You may also get a message asking if you want to install Rtools. A typical Windows setup is missing the toolchain needed to compile R packages from source, so the R folks have packaged the necessary tools in a standalone software bundle called Rtools.

You can find the appropriate Rtools installer through this CRAN page.

  • Follow the links for your R version and operating system.