I am inheriting some code and I think there is room for housekeeping, which includes tidying up the packages game.
In particular, I want both to see what are loaded packages used for, and (most importantly) if there are any loaded-but-unused packages.
The code is long and the packages are many, so I would definitely prefer to automate this process.
As a small example, if I had:
packageload <- c("ggplot2", "readxl")
lapply(packageload, library, character.only = TRUE)
ggplot(diamonds, aes(x = cut)) +
geom_bar()
I would want some output telling me that ggplot() is used from ggplot2 (which is therefore being used as package), and that readxl is currently not used in the project code.