If you are a package author, you are hopefully well aware of upcoming changes in package structure when we move to 2.14 in about a week. One of the changes is that all packages will require a NAMESPACE, and one will be generated for you in the event you do not make one (the R equivalent of your Miranda rights in the US). So being good citizen I was trying to figure this out. Here is the section from R-exts:
1.6.5 Summary – converting an existing package
To summarize, converting an existing package to use a namespace involves several simple steps:
Identify the public definitions and place them in export directives. Identify S3-style method definitions and write corresponding S3method declarations. Identify dependencies and replace any require calls by import directives (and make appropriate changes in the Depends and Imports fields of the DESCRIPTION file). Replace .First.lib functions with .onLoad functions or useDynLib directives.
To ensure I do the right thing here, can someone give a short clear definition/answer (am I breaking a rule by having several small but related questions together?). All answers should take 2.14 into account, please:
Thanks!
I've written a little on this topic at https://github.com/hadley/devtools/wiki/Namespaces.
To answer your questions:
require
should only be used to load suggested packagesCRAN packages have had NAMESPACEs since almost time immortal. Just pick a few of your favorite CRAN packages and look at their NAMESPACE files.
It can be as easy as this one-liner (plus comment) taken from snow:
# Export all names unless they start with a dot
exportPattern("^[^.]")
The run R CMD check
as usual, and you should be fine in most circumstances.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With