tw_check_qid: Ensures that input appears to be a valid Wikidata id

View source: R/tw_check_qid.R

tw_check_qidR Documentation

Ensures that input appears to be a valid Wikidata id

Description

Mostly used internally by other functions.

Usage

tw_check_qid(id, logical_vector = FALSE, non_id_as_NA = FALSE)

Arguments

id

A character vector of one or more Wikidata id.

logical_vector

Logical, defaults to FALSE. If TRUE, returns a logical vector of the same length as input, where TRUE corresponds to seemingly meaningful Q identifiers.

non_id_as_NA

Logical, defaults to FALSE. If TRUE (and if logical_vector is set to FALSE), a vector of the same length is returned, with NA replacing items that are seemingly not meaningful Q identifiers.

Value

A character vector with only strings appearing to be Wikidata identifiers; possibly shorter than input

Examples


tw_check_qid(id = c("Q180099", "q228822", "Not an id", "00180099", NA, "Q5"))

tw_check_qid(
  id = c("Q180099", "q228822", "Not an id", "00180099", NA, "Q5"),
  logical_vector = TRUE
)

tw_check_qid(
  id = c("Q180099", "q228822", "Not an id", "00180099", NA, "Q5"),
  non_id_as_NA = TRUE
)

tidywikidatar documentation built on March 31, 2023, 9:08 p.m.