19

I'm maintaining a package that has a number of helper functions documented with .rd files. As they are not exported, they are not easily accessible by users - this is good. However, they still show up in the index of package help files.

Is there a way to have documentation removed from the index so that it does not clutter it, but still accessible via help?

sebastian-c
  • 15,057
  • 3
  • 47
  • 93
  • Have you checked [this](http://stackoverflow.com/questions/5249673/how-should-i-handle-helper-functions-in-an-r-package) question? There is a comment how to hide the helper functions but not completely sure if it is what you are looking for. – drmariod Sep 08 '15 at 12:38
  • @drmariod Not quite. My problem isn't with visibility of functions themselves, rather that I want them to have standard documentation, but not appear in the index. – sebastian-c Sep 08 '15 at 12:43
  • 1
    If you're using roxygen2 you can use `## ` instead of `#' ` and just comment it. – Tyler Rinker Sep 08 '15 at 13:00
  • 2
    @TylerRinker I was hoping to have a way to still be able to access the documentation using `help`. It's not crucial however, and I might just either leave the index cluttered or go with your suggestion. – sebastian-c Sep 08 '15 at 13:06

2 Answers2

20

There's a field in the Rd file you can add called keywords. Most keywords don't do anything except help you search for functions with one notable exception: internal. Marking a function with the internal keyword removes it from the index. According to the roxygen2 vignette:

@keywords keyword1 keyword2 ... to add standardised keywords. Keywords are optional, but if present, must be taken from the predefined list replicated in the keywords vignette. Keywords are not very useful, except for @keywords internal. Using the internal keyword removes all functions in the associated .Rd file from the documentation index and disables some of their automated tests. A common use case is to both export a function (using @export) and marking it as internal. That way, advanced users can access a function that new users would be confused about if they were to see it in the index.

Adding @keywords internal to the roxygen comments will give the desired result.

sebastian-c
  • 15,057
  • 3
  • 47
  • 93
  • 3
    In your last sentence it should be `@keywords`, not `@keyword`. (Also, what's with not being able to offer an edit of less than 6 characters? There are lots of times when an error of less than 6 characters in a program can have catastrophic results.) – Nobody Sep 19 '17 at 19:37
1

A little bump for people experiencing @keywords internal not working;

I made the mistake of mixing up ??PACKAGENAME and help(package="PACKAGENAME"). Because of this I was left confused why I still saw the documentation of the internals. ?? loads ALL documentation of your package and is not neccesarily the user help index.

Very basic mistake, but there ya go.

Berghopper
  • 57
  • 4