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.
options(tidyverse.quiet = TRUE)
library(tidyverse)
library(usedthese)
library(xts, exclude = "first")
#> Loading required package: zoo
#>
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>
#> as.Date, as.Date.numeric
#>
#> Attaching package: 'xts'
#> The following object is masked from 'package:dplyr':
#>
#> last
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))
#> # A tibble: 2 × 5
#> group a1 a2 first_a1 last_a2
#> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 x 1 2 1 5
#> 2 x 4 5 1 5
In the example below, tribble()
is counted once against
the (originating) tibble package even though it is also loaded by dplyr.
And used_here()
assumes a loaded function is used rather
than a base function of the same name, so dplyr::filter()
,
for example, is counted rather than stats::filter()
.
Both the dplyr and xts packages have first()
and
last()
functions. Because we’ve explicitly excluded
first()
in the library call for xts, the function is
counted against dplyr. However, as there is no similar exclusion for
last()
, this is shown against both packages as a DUPE; a
decision needs to be made as to which should be excluded.
(library()
can take an exclude
character
vector or an include.only
vector.)
The rendered table is assigned the CSS class .usedthese
to help other used_*
functions find and aggregate multiple
tables across one or more websites.
used_here()
Package | Function |
---|---|
[DUPE]dplyr | last[1] |
[DUPE]xts | last[1] |
base | library[3]; options[1] |
dplyr | filter[1]; first[1]; mutate[1]; select[1] |
tibble | tribble[1] |
tidyselect | starts_with[1] |