renv does not detect package as used

I have a basic question about renv.

renv does not detect the package "kableExtra" as being used in my project, even though it is. Therefore, it was not detected with renv::init().

I want to install and track an older version of kableExtra (1.3.4). If I use renv::install("kableExtra@1.3.4"), nothing happens. I can force it with "renv::install("kableExtra@1.3.4",lock=TRUE)", but since renv::status() shows used = '?', renv::snapshot() will remove it from the lock file. Can I force renv to consider a package as used?

renv normally works by scanning through your code and looking for packages that your require() or library() in.

having library(kableExtra) somewhere in your code should do the trick.

2 Likes

Many thanks. It was an old piece of code with

packages <- c('bigstatsr', 'cli', 'doParallel', 'foreach', 'ggtext', 'kableExtra', 'minpack.lm','tidyverse', 'XML')
lapply(packages, require, character.only = TRUE)

For some reason renv recognized all the packages except kableExtra. library() for each package solved the problem. Thanks again!