Search code examples
rroxygen2r-package

function not being added to NAMESPACE


I have a function that I'm trying to add to a package. I am generating the documentation via devtools::document(). The .Rd files for this and ~70 other functions are generated successfully, but this one function is not added to the namespace.

The file can be found at the following link, and perhaps importantly, is called truncate.distribution.r. I have many other functions with periods in the names, so I am almost certain that is not the problem.

However, as I was going through the NAMESPACE, I noticed this line S3method(truncate,distribution), and wondered if the similar name was a coincidence (i.e. comma, as opposed to period). I tried removing the period from the name, and re-generating the documentation and NAMESPACE, and it all worked just fine - that is, the function is exported with the package.

While the altered name works, I would like to learn why it failed and how I can prevent similar failures in the future. Also, I like the original name. :)

Anyone have any thoughts? Much appreciated.


Solution

  • So you guys are right, and it had to do with the periods in the names. The particular file that cause the problem for us was one where the first part of the name ("truncate."...) was already a base function, thus being interpreted as S3methods.

    Thanks to all who answered. I'm not sure why I'm getting voted down - knowing not to use periods in function names is not inherent knowledge, nor is it expressly forbidden anywhere I looked (i.e. Hadley's, or Google's Style Guides).