[R-pkg-devel] Use of assignInNamespace in package
Hugh Parsonage
hugh@p@r@on@ge @end|ng |rom gm@||@com
Thu Feb 7 10:58:45 CET 2019
Hello,
I'm considering a package submission. I have used assignInNamespace,
which is hideous but seems better than the alternatives. I see that it
returns a NOTE on R CMD check, suggesting that it is not absolutely
prohibited, but would require justification.
The justification I would make is that it fixes a spurious warning
emitted by the namespace and that the assignInNamespace call would
require user intervention or the presence of an (unset) package option
or environment variable before being run. The alternatives would be to
use `suppressWarnings` (but this risks suppressing other, valid
warnings), to fork the package and submit the patched version as a
standalone package to CRAN first (which seems excessive or without
merit given the patch would be just one line), or to write a message
on package startup with the intended `assignInNamespace` call,
together with a recommendation to copy and run it before continuing
(which seems worse than assigning it within the package, considering
the message may be copied wrongly, and would have to be done on every
load).
I note the CRAN policy on 'malicious or anti-social' behaviour. My
read of 'Limited exceptions may be allowed in interactive sessions if
the package obtains confirmation from the user.' is that the usage
I've described may be allowed. Agreement with the namespace owner
seems to offer another justification, though I haven't heard back from
the maintainer. (The patch is fairly inconsequential so the lack of
response is understandable.)
I also note the Warning in ?getFromNamespace regarding this function,
but as I said, it seems the least worst option.
Best,
Hugh.
More information about the R-package-devel
mailing list