Order of libraries in the Imports sectiion of DESCRIPTION file

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?

Thanks.
Nikhil

Again, I'm not a packager, and, indeed, according to The Man Himself

I recommend putting one package on each line, and keeping them in alphabetical order. That makes it easy to skim.

So, since this is a rule of convenience, rather than a rule of necessity, the idea that comes to mind is to look at forecast

Imports: colorspace, fracdiff, ggplot2 (>= 2.2.1), graphics, lmtest,
        magrittr, nnet, parallel, Rcpp (>= 0.11.0), stats, timeDate,
        tseries, urca, zoo

Under the assumption that the order of package name space importation matters, it looks like forecast might be comfortable immediately after parallel, since it has no dependencies listed in the following entries.

Other speculations: removing the duplicated packages might work or putting forecast first might let it take care of itself.

I tried moving the forecast package to the beginning but it did not help.

1 Like

Well, another hopefully useful fail on my part :axe::microbe:

I got similar results when I put the forecast package last or in its alphabetical position.

My only guess is that maybe the ordering issue is caused by packages registering S3 methods with the same name. For example, forecast and ggfortify both have an S3 method name autoplot.arima.

devtools::check() with forecast listed after dplyr in the imports:

Click to see output
> devtools::check()
Updating tswgewrapped documentation
Loading tswgewrapped
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Registered S3 methods overwritten by 'ggfortify':
  method                 from    
  autoplot.Arima         forecast
  autoplot.acf           forecast
  autoplot.ar            forecast
  autoplot.bats          forecast
  autoplot.decomposed.ts forecast
  autoplot.ets           forecast
  autoplot.forecast      forecast
  autoplot.stl           forecast
  autoplot.ts            forecast
  fitted.ar              forecast
  fortify.ts             forecast
  residuals.ar           forecast
Registered S3 method overwritten by 'GGally':
  method from   
  +.gg   ggplot2
Registered S3 method overwritten by 'greybox':
  method     from
  print.pcor lava
-- Building ---------------------------------------------------- tswgewrapped --
Setting env vars:
* CFLAGS    : -Wall -pedantic
* CXXFLAGS  : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
--------------------------------------------------------------------------------
√  checking for file 'C:\Users\BLISCJX\Documents\test/DESCRIPTION' (644ms)
-  preparing 'tswgewrapped':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
   Removed empty directory 'tswgewrapped/man'
-  building 'tswgewrapped_1.8.10.tar.gz'
   
-- Checking ---------------------------------------------------- tswgewrapped --
Setting env vars:
* _R_CHECK_CRAN_INCOMING_REMOTE_: FALSE
* _R_CHECK_CRAN_INCOMING_       : FALSE
* _R_CHECK_FORCE_SUGGESTS_      : FALSE
* NOT_CRAN                      : true
-- R CMD check ----------------------------------------------------------------------
-  using log directory 'C:/Users/BLISCJX/AppData/Local/Temp/RtmpwBhd8F/tswgewrapped.Rcheck' (692ms)
-  using R version 3.6.3 (2020-02-29)
-  using platform: x86_64-w64-mingw32 (64-bit)
-  using session charset: ISO8859-1
-  using options '--no-manual --as-cran'
√  checking for file 'tswgewrapped/DESCRIPTION' ... 
-  this is package 'tswgewrapped' version '1.8.10'
-  package encoding: UTF-8
√  checking package namespace information ...
√  checking package dependencies (1.6s)
√  checking if this is a source package ...
√  checking if there is a namespace
√  checking for .dll and .exe files
√  checking for hidden files and directories ...
√  checking for portable file names ...
√  checking serialization versions ... 
√  checking whether package 'tswgewrapped' can be installed (4.7s)
√  checking package directory (1.5s)
√  checking for future file timestamps (964ms)
√  checking DESCRIPTION meta-information (1s)
√  checking top-level files ...
√  checking for left-over files
√  checking index information ...
√  checking package subdirectories (347ms)
√  checking whether the package can be loaded (557ms)
√  checking whether the package can be loaded with stated dependencies (347ms)
√  checking whether the package can be unloaded cleanly ... 
√  checking whether the namespace can be loaded with stated dependencies (350ms)
√  checking whether the namespace can be unloaded cleanly (455ms)
√  checking loading without being on the library search path (1.2s)
-  checking examples ... NONE (478ms)
√  checking for detritus in the temp directory
   
   
-- R CMD check results ------------------------------------- tswgewrapped 1.8.10 ----
Duration: 16.1s

0 errors √ | 0 warnings √ | 0 notes √

devtools::check() with forecast listed last in the imports:

Click to see output
> devtools::check()
Updating tswgewrapped documentation
Loading tswgewrapped
Registered S3 method overwritten by 'GGally':
  method from   
  +.gg   ggplot2
Registered S3 method overwritten by 'quantmod':
  method            from
  as.zoo.data.frame zoo 
Registered S3 methods overwritten by 'forecast':
  method                 from     
  autoplot.Arima         ggfortify
  autoplot.acf           ggfortify
  autoplot.ar            ggfortify
  autoplot.bats          ggfortify
  autoplot.decomposed.ts ggfortify
  autoplot.ets           ggfortify
  autoplot.forecast      ggfortify
  autoplot.stl           ggfortify
  autoplot.ts            ggfortify
  fitted.ar              ggfortify
  fortify.ts             ggfortify
  residuals.ar           ggfortify
Registered S3 method overwritten by 'greybox':
  method     from
  print.pcor lava
-- Building ---------------------------------------------------- tswgewrapped --
Setting env vars:
* CFLAGS    : -Wall -pedantic
* CXXFLAGS  : -Wall -pedantic
* CXX11FLAGS: -Wall -pedantic
--------------------------------------------------------------------------------
√  checking for file 'C:\Users\BLISCJX\Documents\test/DESCRIPTION' (667ms)
-  preparing 'tswgewrapped':
√  checking DESCRIPTION meta-information ... 
-  checking for LF line-endings in source and make files and shell scripts
-  checking for empty or unneeded directories
   Removed empty directory 'tswgewrapped/man'
-  building 'tswgewrapped_1.8.10.tar.gz'
   
-- Checking ---------------------------------------------------- tswgewrapped --
Setting env vars:
* _R_CHECK_CRAN_INCOMING_REMOTE_: FALSE
* _R_CHECK_CRAN_INCOMING_       : FALSE
* _R_CHECK_FORCE_SUGGESTS_      : FALSE
* NOT_CRAN                      : true
-- R CMD check ----------------------------------------------------------------------
-  using log directory 'C:/Users/BLISCJX/AppData/Local/Temp/RtmpUf57Gk/tswgewrapped.Rcheck' (721ms)
-  using R version 3.6.3 (2020-02-29)
-  using platform: x86_64-w64-mingw32 (64-bit)
-  using session charset: ISO8859-1
-  using options '--no-manual --as-cran'
√  checking for file 'tswgewrapped/DESCRIPTION' ... 
-  this is package 'tswgewrapped' version '1.8.10'
-  package encoding: UTF-8
√  checking package namespace information ...
√  checking package dependencies (1.3s)
√  checking if this is a source package ...
√  checking if there is a namespace
√  checking for .dll and .exe files
√  checking for hidden files and directories ...
√  checking for portable file names
√  checking serialization versions
√  checking whether package 'tswgewrapped' can be installed (4.6s)
√  checking package directory (2.2s)
√  checking for future file timestamps (388ms)
√  checking DESCRIPTION meta-information (1s)
√  checking top-level files ...
√  checking for left-over files
√  checking index information ...
√  checking package subdirectories (334ms)
√  checking whether the package can be loaded (550ms)
√  checking whether the package can be loaded with stated dependencies (355ms)
√  checking whether the package can be unloaded cleanly (349ms)
√  checking whether the namespace can be loaded with stated dependencies (344ms)
√  checking whether the namespace can be unloaded cleanly (540ms)
√  checking loading without being on the library search path (1.2s)
-  checking examples ... NONE (458ms)
√  checking for detritus in the temp directory
   
   
-- R CMD check results ------------------------------------- tswgewrapped 1.8.10 ----
Duration: 15.9s

0 errors √ | 0 warnings √ | 0 notes √
1 Like