[R-pkg-devel] How to manage using different packages if available (suggests - imports)

Knut Krueger rhe|p @end|ng |rom krueger-|@m||y@de
Thu Feb 18 16:36:08 CET 2021


The following problem:

there are three packages foo1, foo2 and foo3 to use with the update of a 
package. The availability depends on the configuration of the host 
system. f.e java version

If I write in the Description

...
Suggests: foo1, foo2, foo3
....

inside of functions if have:

functionfoo <- function(data,usingpackage {
.....
foo1, foo2 and foo3
  if (usingpackage == "foo1") {
  do_something
}

.....

if (usingpackage == "foo2") {
  do_something
}
....
if (usingpackage == "foo3") {
  do_something
}

....
}

But of course it is not possible to get a positive check result.
It starts either with the missing package at suggest statement
or if I remove the suggest statement there is an error
   '::' or ':::' imports not declared from:
      ‘foo1’ ‘foo2’ ‘foo3’
    'loadNamespace' or 'requireNamespace' calls not declared from:
      ‘foo1’ ‘foo2’ ‘foo3’

Any hints to solve this issue?



More information about the R-package-devel mailing list