Learn R Programming

PubChemR (version 3.0.0)

has_hits: Check Whether Queries Returned Hits

Description

Returns a named logical vector indicating whether each requested identifier produced hits. This is useful for guarding downstream formatting (for example, `sprintf`) when some identifiers return no results.

Usage

has_hits(object, .which = NULL, ...)

Value

A named logical vector. Names correspond to requested identifiers.

Arguments

object

An object returned from PubChem request wrappers such as `get_cids()`, `get_aids()`, `get_sids()`, and related functions.

.which

Optional character vector of requested identifiers to subset.

...

Additional arguments. Currently unused.

Examples

Run this code
# \donttest{
req <- get_cids(c("aspirin", "definitely_not_real"), namespace = "name")
flags <- has_hits(req)
if (any(flags)) {
  CIDs(req)
}
# }

Run the code above in your browser using DataLab