Reputation: 326
I'm developing an R package where the functions fall into logical groups; broadly, "Input", "Data Munging", "Analysis", "Output", "Info", and "Utils". I want my package index to be split into these major headings, in that order, with functions in each group listed in alphabetical order. I don't want anything silly like multiple cascading levels; one level will be fine.
The R package documentation system (which is otherwise a thing of beauty -- thanks guys!) gives me an index with vignettes and DESCRIPTION at the top, and then all the functions in alphabetical order. I thought that roxygen2 tags like @family
or @describeIn
would do the trick, but they don't. I've also noticed that some packages have their index split by initial function letter, but a quick look at the source code on Github doesn't suggest anything useful. Googling and Stackexchanging doesn't turn up anything beyond some hacks like this, which refers to lattice
.
I can't believe I'm the first person in the history of R who has wanted to do this! I generally assume that reasonable-sounding things will be easy or at least possible in open-source packages -- they're generally written by reasonable people -- but I'm at a loss here.
Upvotes: 7
Views: 490
Reputation: 63
I also have not found a way to create documentation that orders the functions by groups. I like the raster example pointed out by @nicola, where there is an introduction with functions grouped by topic. It was not entirely clear to me whether they had to enter this extra documentation by hand, so I came up with a hack (related to the lattice documentation) that uses roxygen2 @family and will generate a list of similar functions at the top of the documentation automatically. Give the group an @family tag and make sure to give all the other functions in that group the same @family tag:
#' Heading A
#'
#' Functions used for "a" purpose
#' @name A1
#' @family a functions
NULL
#' Heading B
#'
#' Functionsed used for "b" purpose
#' @name A2
#' @family b functions
NULL
#' foo
#' @param x
#' @family a functions
foo <- function(x) x * 10
Upvotes: 1