2026-02-17
file structures of packages
documentation
development cycle
Resource: R packages by Hadley Wickham
declared through DESCRIPTION file
three levels: Suggests, Imports, Depends (weakest to strongest)
package::function() or import them using roxygen tags (@import, @importFrom)Imports rather than Depends. Depends might overwrite a previously loaded function of the same name: Namespaces reference - why Depends is a bad ideaTry to keep dependencies as light as possible: It Depends
DO NOT include tidyverse as a dependency.
pak shows dependencies
❯ checking dependencies in R code ... WARNING
'library' or 'require' call to ‘dplyr’ in package code.
Please use :: or requireNamespace() instead.
See section 'Suggested packages' in the 'Writing R Extensions' manual.
❯ checking dependencies in R code ... WARNING
'::' or ':::' imports not declared from:
‘gh’ ‘lubridate’ ‘purrr’ ‘stringdist’
'library' or 'require' call not declared from: ‘dplyr’
':::' call which should be '::': ‘purrr:::map_chr’
See the note in ?`:::` about the use of this operator.
❯ checking R code for possible problems ... NOTE
ghc: no visible global function definition for ‘hclust’
ghc: no visible global function definition for ‘as.dist’
ghc: no visible global function definition for ‘cutree’
ghc: no visible global function definition for ‘mutate’
ghc: no visible global function definition for ‘group_by’
❯ checking package dependencies ... ERROR
Namespace dependency missing from DESCRIPTION Imports/Depends entries: ‘gh’
❯ checking dependencies in R code ... WARNING
'library' or 'require' call to ‘dplyr’ in package code.
Please use :: or requireNamespace() instead.
See section 'Suggested packages' in the 'Writing R Extensions' manual.
remove any calls to library or require
in the console run usethis::use_package("dplyr") (places package “dplyr” into the DESCRIPTION file)
specifying (minimal) version is optional
Call functions as dplyr::fun or add to function documentation the line:
#' @importFrom dplyr group_by mutate
❯ checking dependencies in R code ... WARNING
'::' or ':::' imports not declared from:
‘gh’ ‘lubridate’ ‘purrr’ ‘stringdist’
'library' or 'require' call not declared from: ‘dplyr’
':::' call which should be '::': ‘purrr:::map_chr’
See the note in ?`:::` about the use of this operator.
add four more packages to DESCRIPTION
usethis::use_package("gh")
usethis::use_package("lubridate")
usethis::use_package("purrr")
usethis::use_package("stringdist")
change ::: to :: in call to purrr::map_chr
❯ checking R code for possible problems ... NOTE
ghc: no visible global function definition for ‘hclust’
ghc: no visible global function definition for ‘as.dist’
ghc: no visible global function definition for ‘cutree’
ghc: no visible global function definition for ‘mutate’
ghc: no visible global function definition for ‘group_by’
all of these problems are solved by using
importFrom pkg function
Might need a call to ?fun to find the package in which a function is defined
importFrom stats hclust as.dist cutree
❯ checking package dependencies ... ERROR
Namespace dependency missing from DESCRIPTION Imports/Depends entries: ‘gh’
another call to usethis::use_package("gh")
❯ checking R code for possible problems ... NOTE
ghc: no visible binding for global variable ‘cluster’
ghc: no visible binding for global variable ‘prefix’
last_pushed: no visible binding for global variable ‘pushed_at’
last_pushed: no visible binding for global variable ‘name’
Undefined global functions or variables:
cluster name prefix pushed_at
Expand the functionality of hello to produce an output of Hello, string! for hello(string).
Insert the corresponding roxygen tags to expand on the documentation
Run devtools::document()
Check that the help for hello is updated