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

epmc_search: populate the hit_count attribute even with zero results #58

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
epmc_search: populate the hit_count attribute even with zero results
  • Loading branch information
arvi1000 committed Jun 12, 2024
commit 2c6462d377313c1a76cf1fecbf244e7b6f73c6be
5 changes: 4 additions & 1 deletion R/epmc_search.r
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ epmc_search <- function(query = NULL,
hits <- epmc_hits(query, synonym = synonym)
if (hits == 0) {
message("There are no results matching your query")
md <- NULL
# return an empty tibble
md <- tibble::tibble()
# populate the hit_count attribute even with zero results
attr(md, "hit_count") <- hits
} else {
limit <- as.integer(limit)
limit <- ifelse(hits <= limit, hits, limit)
Expand Down
Loading