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 to resolve
conflicts. In the example below, ‘dplyr’ has been preferred over stats
for filter()
and lag()
, and over the xts
package for first()
and last()
.
options(tidyverse.quiet = TRUE)
library(conflicted)
library(tidyverse)
conflict_prefer_all("dplyr", quiet = TRUE)
library(usedthese)
library(xts)
#> Loading required package: zoo
#>
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>
#> as.Date, as.Date.numeric
conflict_scout()
#> 4 conflicts:
#> * `filter`: [dplyr]
#> * `first` : [dplyr]
#> * `lag` : [dplyr]
#> * `last` : [dplyr]
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 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.
used_here()
Package | Function |
---|---|
base | library[4], options[1] |
conflicted | conflict_prefer_all[1], conflict_scout[1] |
dplyr | filter[1], first[1], last[1], mutate[1], select[1] |
tibble | tribble[1] |
tidyselect | starts_with[1] |