From 2c6462d377313c1a76cf1fecbf244e7b6f73c6be Mon Sep 17 00:00:00 2001 From: arvi1000 <2406749+arvi1000@users.noreply.github.com> Date: Wed, 12 Jun 2024 13:20:13 -0700 Subject: [PATCH] epmc_search: populate the hit_count attribute even with zero results --- R/epmc_search.r | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/epmc_search.r b/R/epmc_search.r index 20e929c..b9c503d 100644 --- a/R/epmc_search.r +++ b/R/epmc_search.r @@ -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)