I am puzzled by a fact that I noticed when reading the source code of the gamm4 package.
In two places, it imports internal functions from mgcv.
One place is in the gamm4.setup
function (link to code here)
G <- mgcv:::gam.setup(formula,pterms,
data=data,knots=knots,sp=NULL,
min.sp=NULL,H=NULL,absorb.cons=TRUE,sparse.cons=0,gamm.call=TRUE)
Another place is in the gamm4 function (link to code here):
var.summary <- mgcv:::variable.summary(gp$pf,dl,nrow(mf)) ## summarize the input data
In the DESCRIPTION file, it lists mgcv under Depends (link to full DESCRIPTION file here):
Depends: R (>= 2.9.0), methods, Matrix, lme4 (>= 1.0), mgcv (>= 1.7-23)
Furthermore, in NAMESPACE it imports mgcv, although I don't think that's relevant for my question. Link to NAMESPACE here.
This use of internal functions from another package causes a warning if I do exactly the same thing in a package that I'm developing, leaving the following WARNING from R CMD check
:
❯ checking dependencies in R code ... WARNING
Unexported objects imported by ':::' calls:
‘mgcv:::gam.setup’ ‘mgcv:::variable.summary’
See the note in ?`:::` about the use of this operator.
Including base/recommended package(s):
‘mgcv’
However, gamm4 has no NOTEs or WARNINGs on CRAN, and I can confirm by downloading the source code and running R CMD check
on it, that everything is fine for gamm4.
Now my question is:
Note: I'm aware that using an internal still may not be good practice, e.g., as noted in help(":::")
, so my question mainly regards why R CMD check
accepts this.
Edit: thanks to @GaborCsardi's comment, I learnt that using :::
in a package doesn't raise a warning if you are also the maintainer of the package from which you use the function.
For example, if you're the maintainer of the package foo
, you can use foo:::
in another package foo2
without having this warning. Note that this should only work if you use the same email address in the Maintainer
field in DESCRIPTION
.
In your example, Simon Wood is the maintainer of both gamm4
and mgcv
.