5 NAMESPACE
The
NAMESPACE
file is written by devtools when you rundevtools::document()
on your correctly formatted helpfilesYou must specify to
@export
functions you want exported from your package!Whilst it is tempting to
#' @importFrom pkgname fn
the functions you have used from other packages in the roxygen comments before your function definition in most cases you don’t need to, as you should simply call the function with the namespace qualification, e.g., codestats::lm(...)
instead oflm()
Read https://r-pkgs.org/namespace.html many times!
Remember what happens when we load a package - an environment of its objects are placed at the top of R’s search path (figure from here)
Every package has a package environment (the exported functions) and a namespace environment (both exported and internal functions)