This will create a new project with the workshop materials on your local machine, and it will also fork the repository to your GitHub account (you can suppress this with fork = FALSE but there’s no harm in forking).
Install dependencies: Open the project and run renv::restore(prompt = FALSE) to install required R packages.
Verify: If the following example code produces a plot, you’re probably good to go:
Installation instructions depend in whether you’re using Windows, Linux (whichever flavor), or macOS.
We assumethe most recent R version, but all recent versions should work fine.
If you have neither Positron nor RStudio installed, install wither (Positron probably preferred)
Create a local copy of this workshop repository (https://github.com/bips-hb/datatrain_workshop_ml.git), using any one of these options (use whichever you are most familiar with):
Using R and the usethis package: usethis::create_from_github(repo = "https://github.com/bips-hb/datatrain_workshop_ml.git")
Running this in the terminal: git clone https://github.com/bips-hb/datatrain_workshop_ml.git
Using RStudio’s New Project -> Version Control dialog to clone the repository (analogously for whichever editor you’re using).
Install R packages required for the workshop by opening the workshop repository in Positron or RStudio and run renv::restore(prompt = FALSE). {renv} will automatically install all R packages with the correct versions listed in renv.lock.
In some cases, installation with {renv} might fail, and if that happens move on to the next section to install packages manually.
3.1 Manual package installation instructions
Click to expand instructions
You should only need to install all packages manually if you were not able to use renv to install them automatically. (Or if you’re trying to get this code to run in a different environment than this repository)
If you want to “disable” renv so you can manually install packages, open .Rprofile and comment out the following line:
source("renv/activate.R")
The you can directly use {pak} for installation, which will try to automatically install system dependencies on Linux (see next note) if possible:
packages <-c(# Data"palmerpenguins", "mlr3data",# Learner backends"ranger", "xgboost", "kknn", "rpart", "e1071", "randomForest","mlr3verse", "mlr3filters", # installs "mlr3", "mlr3learners", "mlr3viz", "mlr3tuning" ..."precrec", # ROC plots via mlr3, not auto-installed with mlr3viz# Viz / interpretability"rpart.plot", "effectplots",# Plotting / infrastructure, goodies"rmarkdown", "ggplot2", "patchwork", "usethis", "dplyr", "purrr", "ragg")# Installing pak for faster package installationinstall.packages("pak")# Install packages if not available alreadypak::pak(packages)
3.1.1 Linux Note
Click to expand
If you’re working on a Linux distribution such as Ubuntu (or something Ubuntu-based), you may have to install some system packages with sudo apt-get install ... beforehand.
For Ubuntu it would look like this, which you can run in the terminal of your choice: