diff --git a/DESCRIPTION b/DESCRIPTION index 00e768a..b4f1756 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -36,7 +36,7 @@ Imports: tibble, tidyr, rlang -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 Suggests: testthat, knitr, 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) diff --git a/docs/.DS_Store b/docs/.DS_Store index b4f3741..1339fb4 100644 Binary files a/docs/.DS_Store and b/docs/.DS_Store differ diff --git a/man/epmc_annotations_by_id.Rd b/man/epmc_annotations_by_id.Rd index 4d29040..80df5a3 100644 --- a/man/epmc_annotations_by_id.Rd +++ b/man/epmc_annotations_by_id.Rd @@ -36,8 +36,8 @@ full-text articles. } \examples{ \dontrun{ - annotations_by_id("MED:28585529") + epmc_annotations_by_id("MED:28585529") # multiple ids - annotations_by_id(c("MED:28585529", "PMC:PMC1664601")) + epmc_annotations_by_id(c("MED:28585529", "PMC:PMC1664601")) } } diff --git a/man/epmc_ftxt.Rd b/man/epmc_ftxt.Rd index 3923c69..487e2d8 100644 --- a/man/epmc_ftxt.Rd +++ b/man/epmc_ftxt.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/epmc_ftxt.r \name{epmc_ftxt} \alias{epmc_ftxt} -\title{Fetch Europe PMC full texts} +\title{Fetch Europe PMC full text} \usage{ epmc_ftxt(ext_id = NULL) } @@ -14,7 +14,7 @@ All full text publications have external IDs starting 'PMC_'} xml_document } \description{ -This function loads full texts into R. Full texts are in XML format and are +This function loads one full text into R. Full text is in XML format and is only provided for the Open Access subset of Europe PMC. } \examples{ diff --git a/man/europepmc.Rd b/man/europepmc.Rd index 3027064..86d065d 100644 --- a/man/europepmc.Rd +++ b/man/europepmc.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/europepmc.r \docType{package} \name{europepmc} -\alias{europepmc} \alias{europepmc-package} +\alias{europepmc} \title{europepmc - an R client for the Europe PMC RESTful article API} \description{ What is europepmc?: diff --git a/tests/testthat/test_epmc_db.r b/tests/testthat/test_epmc_db.r index 750abe9..83e231c 100644 --- a/tests/testthat/test_epmc_db.r +++ b/tests/testthat/test_epmc_db.r @@ -2,7 +2,10 @@ context("testing epmc_db") test_that("epmc_db returns", { skip_on_cran() - a <- epmc_db("12368864", db = "uniprot", limit = 50) + # as of July 2024, this result only returns 10 results, so limit must + # be <= that + a_limit <- 7 + a <- epmc_db("12368864", db = "uniprot", limit = a_limit) b <- epmc_db("25249410", db = "embl") c <- epmc_db("14756321", db = "uniprot") d <- epmc_db("11805837", db = "pride") @@ -31,7 +34,7 @@ test_that("epmc_db returns", { - expect_equal(nrow(a), 50) + expect_equal(nrow(a), a_limit) # fails correctly expect_error(epmc_db("14756321"), "Please restrict reponse to a database") diff --git a/tests/testthat/test_epmc_search.r b/tests/testthat/test_epmc_search.r index 4c59cf2..8ef0d0e 100644 --- a/tests/testthat/test_epmc_search.r +++ b/tests/testthat/test_epmc_search.r @@ -31,19 +31,19 @@ test_that("epmc_search returns", { expect_is(k, "list") expect_is(l, "data.frame") - #are diminsions correct? + # are dimensions correct? expect_equal(nrow(e), 250) expect_equal(ncol(e), 4) expect_equal(nrow(f), 25) expect_equal(nrow(h), 100) expect_equal(length(i), 125) + expect_equal(nrow(j), 0) expect_equal(nrow(l), 100) # fails correctly expect_message(epmc_search("123haha"), "There are no results matching your query") - expect_null(j) expect_error(epmc_search(query = "malaria", limit = TRUE)) expect_error(epmc_search(query = "malaria", verbose = "kdk")) expect_error(epmc_search(query = "malaria", synonym = "yes"))