You could also use require() instead of !("pak" %in% rownames(installed.packages())) if you wanted to simplify the if statement on whether to install. See here an example copied from the {epiparameter} README.
# check whether {pak} is installed
if(!require("pak")) install.packages("pak")
pak::pak("epiverse-trace/epiparameter")
The
README
currently installs the package when rendered https://github.com/epiverse-trace/cleanepi/blob/main/README.Rmd#L74-L78. I would recommend turning the evaluation of this code chunk off (either witheval=FALSE
or using```r
instead of```{r}
.You could also use
require()
instead of!("pak" %in% rownames(installed.packages()))
if you wanted to simplify theif
statement on whether to install. See here an example copied from the {epiparameter}README
.