Skip to content

Fix package imports (don't use library anymore in functions)

Calls to library are highly unrecommended in R package functions.

The check lists these packages used in CAWET functions (https://forge.inrae.fr/umr-g-eau/cawet/-/jobs/1858879#L945):

Namespaces in Imports field not imported from:
    'CropWat' 'archive' 'beepr' 'colorspace' 'curl' 'data.table'
    'exactextractr' 'fastmap' 'foreign' 'geojsonio' 'ggpubr' 'httr'
    'httr2' 'ncdf4' 'openmeteo' 'readODS' 'rstudioapi' 'shiny' 'stars'
    'tcltk' 'tidytable' 'tidyverse' 'tools'
    All declared Imports should be used.

General recommendation for Using Functions from Package Dependencies in R: choose the lightest tool that keeps your intent clear.

  • Occasional use? → package::function()
  • Frequent use? → @importFrom
  • Heavy dependency? → maybe @import, but sparingly

Good namespace discipline keeps your package clean, explicit, and easy for others to understand.

You should definitely not use tidyverse as a dependency since it contains all the packages in the tidyverse (dplyr, tidyr, ggplot2, readr, ...)