9  Installing R Packages

We will be using specific R packages for the workshop, so you will need to install them. To make it easier, we’ve created a custom R package called r3 that will install all the necessary packages for you for this workshop. Run these functions in the Console to install the packages.

  1. Install the {pak} package:

    Console
    install.packages("pak")
  2. Install our custom r3 helper package for this workshop:

    Console
    pak::pak("rostools/r3")
  3. Install the necessary packages for the workshop:

    Console
    r3::install_packages_advanced()
Warning

You might encounter an error when running this code. That’s ok, you can fix it if you restart R by going to “Sessions -> Restart R” and re-run the code in items 2 and 3, it should work. If that also doesn’t work, try to complete the other tasks, complete the survey, and let us know you have a problem in the survey.

Note: When you see a command like something::something(), for example with r3::install_packages_advanced(), you would “read” this as:

R, can you please use the install_packages_advanced() function from the r3 package.

The normal way of doing this would be to load the package with library(r3) and then running the command (install_packages_advanced()). But by using the ::, we tell R to directly use a function from a package, without needing to load the package and all of its other functions too. We use this trick because we only want to use the install_packages_advanced() command from the r3 package and not have to load all the other functions as well. In this workshop we will be using :: often.