A wrapper of tw_filter() that defaults to keep only "instance of" (P31)
"human being" (Q5).
Usage
tw_filter_people(
search,
language = tidywikidatar::tw_get_language(),
response_language = tidywikidatar::tw_get_language(),
limit = 10,
include_search = FALSE,
stop_at_first = TRUE,
wait = 0,
overwrite_cache = FALSE,
cache_connection = NULL,
disconnect_db = TRUE
)Arguments
- search
A data frame generated by
tw_search(), or a search query. If a data frame is given, language and limits are ignore.- language
Language to be used for the search. Can be set once per session with
tw_set_language(). If not set, defaults to "en". For a full list, see the dedicated Wikimedia page.- response_language
Language to be used for the returned labels and descriptions. Corresponds to the
uselangparameter of the MediaWiki API, as described in the official documentation. Can be set once per session withtw_set_language(). If not set, defaults to "en". For a full list, see all available language codes.- limit
Maximum numbers of responses to be given.
- include_search
Logical, defaults to
FALSE. IfTRUE, the search is returned as an additional column.- stop_at_first
Logical, defaults to TRUE. If TRUE, returns only the first match from the search that satisfies the criteria.
- wait
In seconds, defaults to 0. Time to wait between queries to Wikidata. If data are cached locally, wait time is not applied. If you are running many queries systematically you may want to add some waiting time between queries.
- overwrite_cache
Defaults to
FALSE. IfTRUE, overwrites cache.- cache_connection
Defaults to
NULL. IfNULL, and caching is enabled,tidywikidatarwill use a local sqlite database. A custom connection to other databases can be given (see vignettecachingfor details).- disconnect_db
Defaults to
TRUE. IfFALSE, leaves the connection to cache open.
Examples
tw_search("Ruth Benedict")
#> # A tibble: 5 × 3
#> id label description
#> <chr> <chr> <chr>
#> 1 Q228822 Ruth Benedict American a…
#> 2 Q28002866 Ruth Benedict Prize LGBT anthr…
#> 3 Q80896797 Ruth Benedict scientific…
#> 4 Q58589016 Ruth Benedict, Boasian Anthropology, and the Problem o… article by…
#> 5 Q124712914 Ruth Benedict on Netherlanders journal ar…
tw_search("Ruth Benedict") %>%
tw_filter_people()
#> # A tibble: 1 × 3
#> id label description
#> <chr> <chr> <chr>
#> 1 Q228822 Ruth Benedict American anthropologist and folklorologist (1887-1948)