TNC-NMFO / NWLAND

carbon accounting model
0 stars 0 forks source link

confirm CALAND scripts (e.g. write_caland_input.r) install and load required packages #79

Open sbassett opened 2 years ago

sbassett commented 2 years ago

The scripts we use to call the CALAND functions includes code to install and load required packages. I think some of this is to find missing packages before the slow process of reading the source scripts to memory.

Remove these references to packages that are not directly used by the script. The code necessary to ensure the required packages are installed by the script that depends on them should be added to each dependent script. [This may already happen, but I don't want to delete the potentially unnecessary code before confirming.]

Make this code in the 'NWLAND run' scripts unecessary and then remove it:

# required packages
packages <- c('XLConnect', 'ggplot2', 'gtable', 'munsell')
# install package that aren't yet installed
installed_packages <- packages %in% rownames(installed.packages())
if (any(installed_packages == FALSE)) {
  install.packages(packages[!installed_packages])
}
# load installed packages
invisible(lapply(packages, library, character.only = TRUE))