Is it possible to include a "conditional import" in a package's DESCRIPTION file?
For example, I am developing a package which schedules system tasks. On Windows this is achieved with Task Scheduler and the taskscheduleR package, on unix with the cronR package. So intuitively it would be useful to do something like the following:
DESCRIPTION
Package: pkgname
Version: 0.0.1
[more fields]
Imports:
dplyr,
if (.Platform$OS.type == "windows") "taskscheduleR" else "cronR",
tidyr
I suppose it would be possible to write an .onAttach() or similar which checks the system type and installs the relevant package if not already present, but that doesn't seem like a particularly nice solution - firstly, it relies on the user attaching the package while connected to the web before they can use it, and secondly it breaks the formal dependency chain.
My current approach is to include both packages in Suggests, with the responsibility then on the user to install the correct package for their system.