Accessor returning the per-dimension coverage breakdowns of an
sm_coverage_audit() result as a single flat (long) tibble, optionally
filtered to one dimension.
Arguments
- x
An
sm_coverageobject.- dimension
Optional dimension name (e.g.
"year") to filter to.- tidy
Logical (default
TRUE). The stable long contract: returns columnsdimension,level,n_reference,n_matched,recall,n_corpus,precision,f1. Withtidy = FALSE, the legacy recall-only shape (dimension,level,n_reference,n_matched,recall) is returned for backward compatibility.
Value
A tibble (see tidy). Type-stable: a 0-row tibble with the
documented columns when there are no breakdowns. Slices present on only one
side (corpus vs reference) carry NA in the other side's counts/metric.
Details
This accessor honours the package's accessor return-type stability contract
(see scimapR-stability): with tidy = TRUE the column set is guaranteed
and will only change via a lifecycle deprecation.
Examples
corpus <- sm_example_corpus(n_works = 30, seed = 1)
ref <- corpus$works[1:25, c("work_id", "doi", "title", "year")]
cov <- sm_coverage_audit(corpus, ref, by = "year")
sm_coverage_breakdowns(cov, dimension = "year")
#> # A tibble: 9 × 8
#> dimension level n_reference n_matched recall n_corpus precision f1
#> <chr> <chr> <int> <int> <dbl> <int> <dbl> <dbl>
#> 1 year 2015 1 1 1 1 1 1
#> 2 year 2016 2 2 1 2 1 1
#> 3 year 2017 2 2 1 3 0.667 0.8
#> 4 year 2018 2 2 1 2 1 1
#> 5 year 2020 6 6 1 8 0.75 0.857
#> 6 year 2021 3 3 1 4 0.75 0.857
#> 7 year 2022 3 3 1 4 0.75 0.857
#> 8 year 2023 3 3 1 3 1 1
#> 9 year 2024 3 3 1 3 1 1