I have several R packages containing many datasets I'd like to classify according to applicable methods and have this information searchable in the documentation and hopefully the associated pkgdown site.
Here is a sample, classified with tags in an Excel file
In the documentation, or perhaps just the pkgdown site what would be useful is the "inverse table" of tags, with links to the associated datasets, something like:
tag datasets
ca AirCrash, Burt, Bartlett, ...
glm Accident, Cormorants, ...
loglinear Abortion, Accident, Alligator, Bartlett, ...
...
I need to figure out how to do that, and incorporate it into the pkgdown site.
The final step is to turn the list of datasets under each tag into links in a vignette or other documentation for the pkgdown site. I can do this now as follows, by turning dset into [dset](help(dset)) in the table.
#' ## add links to the names of datasets
#' This function is designed to work with the `pkgdown` site,
#' Turn each dataset into a link to `help(dataset)`
add_links <- function(dsets,
sep = "; ") {
names <- stringr::str_split_1(dsets, sep)
names <- glue::glue("[{names}](help({names}))")
glue::glue_collapse(names, sep = sep)
}
# add_links("Bartlett; Fungicide")
tag_dset |>
dplyr::select(-tag) |>
dplyr::mutate(datasets = purrr::map(datasets, add_links)) |>
knitr::kable()
But AFAICS, this won't work in an ordinary vignette; I think CRAN will object loudly.
It should work when pkgdown turns it into an article. Where can I put this in my package?
For anyone interested, here is the source of my current Rmd file: