--- title: "Getting Started" description: | Add a summary of R package & function usage to a Quarto document. output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Getting Started} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) ``` To add a summary table of package & function usage to the foot of a Quarto document, add `used_here()` to the end of the code. A separate code chunk with an appropriate heading is suggested but not essential. The package author recommends using the [conflicted package](https://conflicted.r-lib.org) to resolve conflicts. In the example below, 'dplyr' has been preferred over stats for `filter()` and over the xts package for `last()`. An alternative approach to using conflicted is to use the `exclude` or `include.only` argument in `library()`. This is also shown below with the xts version of `first` excluded and hence the dplyr version preferred. ## Some code ```{r setup} options(tidyverse.quiet = TRUE) options(xts.warn_dplyr_breaks_lag = FALSE) library(conflicted) library(dplyr) library(tibble) conflicts_prefer(dplyr::filter, dplyr::last) library(usedthese) library(xts, exclude = "first") conflict_scout() ``` ## More code ```{r} tribble(~group, ~a1, ~a2, ~b1, "x", 1, 2, 3, "x", 4, 5, 6, "y", 7, 8, 9) |> select(-starts_with("b")) |> filter(group == "x") |> mutate(first_a1 = first(a1), last_a2 = last(a2)) ``` ## Summary of usage In the example below, `tribble()` is counted once against the (originating) tibble package even though it is also loaded by dplyr. And had we not used the conflicted package, `filter()` for example would have shown against the package name "dplyr, stats". The rendered table is assigned the CSS class `.usedthese` to help other `used_*` functions find and aggregate multiple tables across one or more websites. ```{r warning=FALSE} used_here() ```