# Bad
<- function() {
help_compute # ... Lots of code ...
}
#' My public function
#'
#' This is where the documentation of my function begins.
#' ...
#' @export
<- function() {
do_something_cool # ... even more code ...
help_compute()
}
6 Files
The majority of advice in Chapter 1 also applies to files in packages. Important differences are described below.
6.1 Names
If a file contains a single function, give the file the same name as the function.
If a file contains multiple related functions, give it a concise, but evocative name.
Deprecated functions should live in a file with
deprec-
prefix.
6.2 Organisation
In a file that contains multiple functions, public functions and their documentation should appear first, with private functions appearing after all documented functions. If multiple public functions share the same documentation, they should all immediately follow the documentation block.
See Chapter 7 for more thorough guidance on documenting functions in packages.
# Good
#' Lots of functions for doing something cool
#'
#' ... Complete documentation ...
#' @name something-cool
NULL
#' @describeIn something-cool Get the mean
#' @export
<- function(x) {
get_cool_mean # ...
}
#' @describeIn something-cool Get the sum
#' @export
<- function(x) {
get_cool_sum # ...
}