Related functions listed together in R package documentation
Asked Answered
K

1

7

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.

Killebrew answered 29/10, 2016 at 12:2 Comment(1)
I don't think it can be done. If I were in you, I'd follow what have been done for other packages, raster for example (see cran.r-project.org/web/packages/raster/raster.pdf): a big introduction with all the functions summarized by topic.Casseycassi
P
1

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
Polite answered 25/5, 2018 at 22:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.