[Rd] Questions about imports to a namespace

Simon Knapp sleepingwell at gmail.com
Tue Jul 3 04:53:57 CEST 2012


Hi,

I am a bit unsure about using imports in packages and have a few
questions. I'm sure the answer to some of these is 'it depends', but
I'm interested in what others think and 'best practices' when this is
the case.



1) If I use an import or importFrom declaration in a NAMESPACE, should
I also qualify the package in calls to the imported function (e.g.
maptools::readShapePoly)?

2) If the 'best practice' is to qualify the calls, when does one stop;
e.g. is it good/bad to say base::sapply?

3) If one is calling a (S3) generic, should one qualify the namespace?
Can this cause problems?

4) Is it better to check for arguments that are missing, or use a
default value of, say, NA; i.e. is missing(arg) preferable to
is.na(arg)?

5) I would like to declare a (S3) generic 'cleanup(x)' but
'cleanup(...)' already exists in R.utils, which my package depends on.
Should I do it?

6) I am used to writing 'requires(package)' for each package I use
within a function. If I have used import or importFrom in my
NAMESPACE, should I still do this?



Looking forward to your advice,
Simon Knapp



More information about the R-devel mailing list