16.11 Documenting functions

  • Most commonly documented object
  • Three common tags:
    1. @param name description: describes the function’s inputs or parameters.
      • These need to be documented
      • Multiple arguments can be documented in one place @param x,y description
    2. @examples
      • Provides executable code on how to use the function in practice
      • Must run without errors or use \dontrun{}
      • Keep in mind: Most users will look at examples first
    3. @return
      • Describes the output from the function.
  • Addional tags
  • Keep style conventions top of mind
    • Check out the book for more details
  • ggplot2 example