tomaszaba / ipccheckr

Toolkit for Performing IPC Acute Malnutrition-related Data Checks
GNU General Public License v3.0
2 stars 0 forks source link

note on NAMESPACES in Imports field of DESCRIPTION #3

Closed ernestguevarra closed 4 months ago

ernestguevarra commented 4 months ago

I performed devtools::check() and saw this:

── R CMD check results ───────────────────────────────────────────────────────────────────────────── ipccheckr 0.0.0.9000 ────
Duration: 12.5s

❯ checking dependencies in R code ... NOTE
  Namespaces in Imports field not imported from:
    ‘dplyr’ ‘ggplot2’ ‘nipnTK’ ‘zscorer’
    All declared Imports should be used.

0 errors ✔ | 0 warnings ✔ | 1 note ✖

You will probably use them eventually, but highlighting here so that you take note and be careful with adding Imports before you actually use them.

Also, once you start using these dependencies, note that you need to specify which functions you are specifically importing in the docs. I usually (and I think Hadley recommends this as well) have an R file in the R directory that is named NAME_OF_PACKAGE-package.R where you put roxygen documentation like this:

#' @importFrom NAME_OF_PACKAGE_DEPENDENCY NAME_OF_FUNCTION
tomaszaba commented 4 months ago

Yes, I have not used them yet, but plan to use in some functions. I saw the error, but I ignored taking action because I knew what was about and that it would be fixed down the road as I use them. But I got your advice of declaring dependencies when I am about to use to avoid such issues. This is well noted, thanks.

And yes, I would prefer to use this approach: #' @importFrom NAME_OF_PACKAGE_DEPENDENCY NAME_OF_FUNCTION instead of package::function in the code, as it makes the code to busy.