`PubMatrix()` counts publications for all pairwise combinations of two term sets using the 'NCBI' Entrez 'E-utilities' API. It returns a matrix-like data frame with rows corresponding to terms in `B` and columns corresponding to terms in `A`.

PubMatrix(
  file = NULL,
  A = NULL,
  B = NULL,
  API.key = NULL,
  Database = "pubmed",
  daterange = NULL,
  outfile = NULL,
  export_format = NULL
)

Arguments

file

Optional path to a text file containing search terms. The file must contain a `#` separator line between the `A` and `B` term lists. Used only when `A` and `B` are both `NULL`.

A

Character vector of search terms for matrix columns.

B

Character vector of search terms for matrix rows.

API.key

Optional 'NCBI' API key.

Database

Character scalar. One of `"pubmed"` or `"pmc"`.

daterange

Optional numeric vector of length 2 giving `c(start_year, end_year)`.

outfile

Optional output file stem used when `export_format` is set.

export_format

Optional export format: `"csv"` or `"ods"`.

Value

A data frame of publication counts with rows named by `B` and columns named by `A`.

Details

Examples and vignettes should avoid live web queries during package checks. This function performs live requests to 'NCBI' and may fail when there is no internet connectivity or when the service is unavailable.

Examples

# \donttest{
A <- c("WNT1", "WNT2")
B <- c("FZD1", "FZD2")
result <- PubMatrix(A = A, B = B, Database = "pubmed", daterange = c(2020, 2023))
print(result)
#>      WNT1 WNT2
#> FZD1   10    1
#> FZD2    2    4
# }

try(PubMatrix(A = NULL, B = NULL, file = NULL))
#> Error : Either provide vectors A and B, or specify a file containing search terms.
try(PubMatrix(A = "a", B = "b", Database = "invalid_db"))
#> Error : Database must be one of 'pubmed' or 'pmc'.