It seems like the order in which the packages are specified in the Imports section of the DESCRIPTION file seems to impact the working. The general recommendation is to specify the packages in alphabetical order. My current Imports section looks like this.
Imports: assertr, doParallel, dplyr, ggfortify, GGally, ggplot2, magrittr, nnfor, rlang, pander, parallel, patchwork, purrr, R6, RColorBrewer, Rfast, tibble, tictoc, tswge, vars, forecast
I had to move the forecast import to the end. If I did not do that and specified it alphabetically, it complained about the lattice package not being found.
I am not sure what the issue is but if anyone could shed some light on this, it would be greatly appreciated. Does the order of the packages in the Imports section matter?