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")
::install_github("richardjtelford/checker") remotes
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:
recommended: 4.3.0
minimum: 4.2.0
packages:
tidyverse:
recommended: 2.0.0
here: NA
quarto: NA
rstudio:
recommended: 2023.03.0
options:
save_workspace:
value: never
message: >
Improve reproducibility by never saving the workspace.
Menu tools > Global options > General
load_workspace:
value: FALSE
message: >
Set load workspace to FALSE to improve reproducibility.
Menu tools > Global options > General
rainbow_parentheses:
value: TRUE
message: >
Rainbow parentheses make it easier to spot missing parentheses.
Menu tools > Global options > Code > Display
soft_wrap_r_files:
value: TRUE
message: >
Soft wrap files so you do not need to scroll sideways.
Menu tools > Global options > Code > Editing
insert_native_pipe_operator:
value: TRUE
message: >
Use the native pipe operator '|>'.
Menu tools > Global options > Code > Editing
quarto:
recommended: 1.3.262
git: NA
---
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.