I'd like to use pacman's p_load function. I've read through the documentation and understand how to pass multiple packages into the function directly. However, I'd like to store the package names separately and feed them into pacman so that I can use this same 'list' to later test that the packages have been loaded into the environment.
Based on the documentation, pacman is expecting a character vector. my first attempt was:
pkg_list <- as.vector(c("tidyverse", "forecast")
or
pkg_list <- "tidyverse, forecast"
followed by:
pacman::p_load(pkg_list)
or
pacman::p_load(pkg_list, character.only = FALSE)
Which all return the same error stating:
package ‘pkg_list’ is not available
Fine, it's obviously looking for a package called pkg_list instead of the contents of the object so I also tried using a list and unlisting it in the p_load statement, using eval, etc. but p_load always seems to evaluate whatever is input as a literal.
Just trying to better understand why and how to escape that literal evaluation if possible.