I would like to add a fallback dependency to my package. The problem is that I want to make this CRAN compatible and cannot figure out how to do it correctly.
In particular, I want to use data.table fread / fwrite
. Other than that, I do not want to have a complete data.table dependency. If data.table
not installed, my package should simply revert to using standard read.csv
and write.csv
.
I saw this similar thread: The correct way to handle additional package dependencies
and also used a technique similar to what @Hadley suggested in the comments:
req <- require(data.table)
if(req){
data.table::fwrite(...)
} else {
write.csv(...)
}
This works, but when I start CHECK I get a NOTE:
'library' or 'require' call to ‘data.table’ in package code.
Please use :: or requireNamespace() instead.
This means that I will not get it for CRAN supervisors ...
What is the right way to handle this?