One of the challenges with teaching R is that some students come to practicals with very old versions of R, or without critical packages installed. There are several solutions to this:
renv
package to install packages listed in a lockfileOne problem with these options is that they take control of package installation, rather than giving the student practice installing packages.
The checker
attempts to be an alternative solution. It checks whether the recommended (or more recent) versions of R, RStudio and packages, as specified in a yaml file, are installed and that recommended RStudio options are set. A sample yaml file is included in the installation. One can also be supplied with a URL or path.
You can install the development version of checker
from GitHub with:
# install.packages("remotes")
remotes::install_github("richardjtelford/checker")
The function chk_requirements()
is the only function the user needs to run.
library(checker)
chk_requirements()
#> → Date = 2023-04-26 14:06:33.580533
#> → os = Ubuntu 18.04.6 LTS
#> ✖ Are you using RStudio?
#> ✔ R version 4.3.0 is installed
#> ✔ quarto version 1.3.262 is installed
#> ✔ git version 2.17.1 is installed
#> → Checking R packages
#> ✔ tidyverse version 2.0.0 is installed
#> ✔ here version 1.0.1 is installed
#> ✔ quarto version 1.2 is installed
#> ✖ You have some issues that need addressing
By default, chk_requirements()
uses a yaml file included in the installation. To run chk_requirements()
with your own set of requirements, you can use a URL or file path.
chk_requirements(path = url("https://raw.githubusercontent.com/richardjtelford/checker/main/inst/default.yaml"))
Below is the yaml file included in the installation. It can be edited to meet your requirements by hand or with the function chk_make()
which takes data.frames of recommended programs, packages, and RStudio options as arguments. Recommended and/or minimum version and any message can be included in these data.frames.
---
:
R: 4.3.0
recommended: 4.2.0
minimum:
packages:
tidyverse: 2.0.0
recommended: NA
here: NA
quarto:
rstudio: 2023.03.0
recommended:
options:
save_workspace: never
value: >
message
Improve reproducibility by never saving the workspace.> Global options > General
Menu tools :
load_workspace: FALSE
value: >
messageFALSE to improve reproducibility.
Set load workspace to > Global options > General
Menu tools :
rainbow_parentheses: TRUE
value: >
message
Rainbow parentheses make it easier to spot missing parentheses.> Global options > Code > Display
Menu tools :
soft_wrap_r_files: TRUE
value: >
message
Soft wrap files so you do not need to scroll sideways.> Global options > Code > Editing
Menu tools :
insert_native_pipe_operator: TRUE
value: >
message'|>'.
Use the native pipe operator > Global options > Code > Editing
Menu tools :
quarto: 1.3.262
recommended: NA
git---
The accepted keys are
All keys are optional. The first four take “recommended” and “minimum” to specify the recommended and minimum versions (if only one of “recommended” and “minimum” is set, they are treated in the same). If any version is acceptable, use NA.
The “rstudio” key also accepts an options field, which takes the name with value set to the recommended value and an optional message. A list of RStudio options can be found with usethis:::rstudio_prefs_read()
.
The “packages” key has an element for each package installed. These take the same recommended” and “minimum” fields as above, and also a “message” field which is printed in the package is not installed (the “>” lets the message span several lines). The message could be used to point to the location of packages not available on CRAN.
The dashes denote the start and end of the yaml are optional. The formatting with white space must be followed.