Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tracking coverage of OA entities #211

Merged
merged 26 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export(authors2df)
export(concepts2df)
export(funders2df)
export(get_coverage)
export(institutions2df)
export(oa2bibliometrix)
export(oa2df)
Expand Down
112 changes: 112 additions & 0 deletions R/openalexR-coverage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#' Get coverage of OpenAlex fields in openalexR
#'
#' @param entity The OA entity to inspect field coverage for. Returns
#' information for all fields if `NULL` (default).
#'
#' @return Data frame of field coverage information
#' @export
#'
#' @seealso oa_entities()
#' @examples
#' oa_entities()
#' head(get_coverage(entity = "works"))
get_coverage <- function(entity = NULL) {
if (!is.null(entity)) {
entity <- match.arg(entity, oa_entities())
oa2df_coverage[[entity]]
} else {
oa2df_coverage
}
}

#' @keywords internal
oa2df_coverage <- list()

oa2df_coverage$works <- tibble::tribble(
~original, ~covered_by, ~comments,
"abstract_inverted_index", "ab", "reconstructed from inverted index",
"apc_list", NA, NA,
"apc_paid", NA, NA,
"authorships", "author", NA,
"best_oa_location", NA, NA,
"biblio", "volume", NA,
"biblio", "issue", NA,
"biblio", "first_page", NA,
"biblio", "last_page", NA,
"cited_by_api_url", "cited_by_api_url", NA,
"cited_by_count", "cited_by_count", NA,
"cited_by_percentile_year", NA, NA,
"concepts", "concepts", NA,
"corresponding_author_ids", NA, "reconstructable from `author$is_corresponding`",
"corresponding_institution_ids", NA, "reconstructable from `author$is_corresponding`",
"countries_distinct_count", NA, "reconstructable from `author$institution_country_code`",
"counts_by_year", "counts_by_year", NA,
"created_date", NA, NA,
"display_name", "display_name", NA,
"doi", "doi", NA,
"fulltext_origin", NA, NA,
"grants", "grants", NA,
"has_fulltext", "any_repository_has_fulltext", NA,
"id", "id", NA,
"ids", "ids", NA,
"indexed_in", NA, NA,
"institutions_distinct_count", NA, "reconstructable from `author$institution_id`",
"is_paratext", "is_paratext", NA,
"is_retracted", "is_retracted", NA,
"keywords", NA, NA,
"language", "language", NA,
"locations", NA, NA,
"locations_count", NA, NA,
"mesh", NA, NA,
"ngrams_url", NA, "see `oa_ngrams()`",
"open_access", "is_oa_anywhere", "see PR #135",
"open_access", "oa_status", NA,
"open_access", "oa_url", NA,
"primary_location", "is_oa", NA,
"primary_location", "so", NA,
"primary_location", "so_id", NA,
"primary_location", "host_organization", NA,
"primary_location", "issn_l", NA,
"primary_location", "url", NA,
"primary_location", "pdf_url", NA,
"primary_location", "license", NA,
"primary_location", "version", NA,
"primary_topic", NA, NA,
"publication_date", "publication_date", NA,
"publication_year", "publication_year", NA,
"referenced_works", "referenced_works", NA,
"referenced_works_count", NA, "reconstructable from `referenced_works`",
"related_works", "related_works", NA,
"sustainable_development_goals", NA, NA,
"title", "display_name", NA,
"topics", NA, NA,
"type", "type", NA,
"type_crossref", NA, NA,
"updated_date", NA, NA
)

oa2df_coverage$authors <- tibble::tribble(
~original, ~covered_by, ~comments,
"id", "id", NA,
"orcid", "orcid", NA,
"display_name", "display_name", NA,
"display_name_alternatives", "display_name_alternatives", NA,
"works_count", "works_count", NA,
"cited_by_count", "cited_by_count", NA,
"summary_stats", NA, NA,
"ids", "ids", NA,
"affiliations", "affiliation_display_name", NA,
"affiliations", "affiliation_id", NA,
"affiliations", "affiliation_ror", NA,
"affiliations", "affiliation_country_code", NA,
"affiliations", "affiliation_type", NA,
"affiliations", "affiliation_lineage", NA,
"affiliations", "affiliations_other", NA,
"last_known_institution", NA, "first entry in `affiliation_id`",
"last_known_institutions", NA, "`affiliation_id` + `affiliations_other`",
"x_concepts", "x_concepts", NA,
"counts_by_year", "counts_by_year", NA,
"works_api_url", "works_api_url", NA,
"updated_date", NA, NA,
"created_date", NA, NA
)
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ reference:
- countrycode
- concept_abbrev
- oa_entities
- get_coverage
- oa2bibliometrix
25 changes: 25 additions & 0 deletions man/get_coverage.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions tests/testthat/test-coverage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
test_that("field coverage information is up to date", {
skip_on_cran()
cols <- lapply(get_coverage(), function(x) {
covered_by <- x$covered_by[!is.na(x$covered_by)]
# Additional fields from the parent Search entity
c(covered_by, "relevance_score")
})

# Works
w <- oa_fetch("works", options = list(sample = 1))
expect_true(all(colnames(w) %in% cols$works))

# Authors
a <- oa_fetch("authors", options = list(sample = 1))
expect_true(all(colnames(a) %in% cols$authors))
})
Loading