Basics
library(dplyr, warn.conflicts = FALSE)
# Use dverse and the universe of packages you want to document
library(dverse)
library(tools)
library(datasets)
universe <- c("datasets", "tools")
url_template <- "https://www.rdocumentation.org/packages/{package}/versions/3.6.2/topics/{topic}.html"
documentation <- document_universe(universe, url_template = url_template)
documentation
#> # A tibble: 228 × 5
#> topic alias title concept package
#> <chr> <chr> <chr> <chr> <chr>
#> 1 <a href=https://www.rdocumentation.org/packages/… .pri… Prin… Utilit… tools
#> 2 <a href=https://www.rdocumentation.org/packages/… Adob… Conv… Datase… tools
#> 3 <a href=https://www.rdocumentation.org/packages/… AirP… Mont… Datase… datase…
#> 4 <a href=https://www.rdocumentation.org/packages/… BJsa… Sale… Datase… datase…
#> 5 <a href=https://www.rdocumentation.org/packages/… BOD Bioc… Datase… datase…
#> 6 <a href=https://www.rdocumentation.org/packages/… CO2 Carb… Datase… datase…
#> 7 <a href=https://www.rdocumentation.org/packages/… CRAN… CRAN… NA tools
#> 8 <a href=https://www.rdocumentation.org/packages/… Chic… Weig… Datase… datase…
#> 9 <a href=https://www.rdocumentation.org/packages/… DNase Elis… Datase… datase…
#> 10 <a href=https://www.rdocumentation.org/packages/… EuSt… Dail… Datase… datase…
#> # ℹ 218 more rows
select(documentation, topic)
#> # A tibble: 228 × 1
#> topic
#> <chr>
#> 1 <a href=https://www.rdocumentation.org/packages/tools/versions/3.6.2/topics/…
#> 2 <a href=https://www.rdocumentation.org/packages/tools/versions/3.6.2/topics/…
#> 3 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> 4 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> 5 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> 6 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> 7 <a href=https://www.rdocumentation.org/packages/tools/versions/3.6.2/topics/…
#> 8 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> 9 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> 10 <a href=https://www.rdocumentation.org/packages/datasets/versions/3.6.2/topi…
#> # ℹ 218 more rows
You may generate a clickable table is with
knitr::kable()
.
pick <- documentation |> select(topic, title, concept, package)
pick |>
head() |>
knitr::kable(col.names = NULL)
.print.via.format | Printing Utilities | Utilities | tools |
Adobe_glyphs | Conversion Tables between Character Sets | Datasets available by data() | tools |
AirPassengers | Monthly Airline Passenger Numbers 1949-1960 | Datasets available by data() | datasets |
BJsales | Sales Data with Leading Indicator | Datasets available by data() | datasets |
BOD | Biochemical Oxygen Demand | Datasets available by data() | datasets |
CO2 | Carbon Dioxide Uptake in Grass Plants | Datasets available by data() | datasets |
You may generate a searchable table with
DT::datatable()
.
# `escape = FALSE` shows the link (defaults to showing the underlying URL)
pick |> DT::datatable(escape = FALSE)
Organization and customization
In a meta-package you may organize the documentation of the entire
universe in a single place, maybe organized by package or concept (via
#' @family
). You may create your own custom tables with
DT
or other packages.
custom_table <- function(data, search = "") {
DT::datatable(
data,
escape = FALSE,
rownames = NULL,
options = list(
# fti = f: filter, t: table, i: information
dom = "fti", search = list(search = search)
)
)
}
- Datasets available by
data()
by_concept <- filter(pick, concept == "Datasets available by data()")
by_concept |> custom_table(search = "car")
- Documentation in
tools
by_package <- filter(pick, package == "tools")
by_package |> custom_table(search = "Utilities")
Presentation
In a meta-package, you may use dverse in an article, then use it to override the default Reference component.
For an example see the pkgdown Reference of dverse and follow the link to its source and see how it’s configured in _pkgdown.yml.