Skip to contents

Filters results by adding conditions

Usage

spq_filter(
  .query = NULL,
  ...,
  .label = NA,
  .within_box = c(NA, NA),
  .within_distance = c(NA, NA)
)

Arguments

.query

a list with elements of the query

...

variables by which to arrange (or SPARQL strings escaped with spq(), or strings, see examples)

.label

[Deprecated] See spq_label().

.within_box

if provided, rectangular bounding box for the triple query. Provided as list(southwest=c(long=...,lat=...),northeast=c(long=...,lat=...))

.within_distance

if provided, circular bounding box for the triple query. Provided as list(center=c(long=...,lat=...), radius=...), with radius in kilometers. The center can also be provided as a variable (for instance, "?location") for the center coordinates to be retrieved directly from the query.

Value

A query object

Some examples

spq_init() %>%
spq_filter(item == wdt::P31(wd::Q13442814))

# Lexemes in English that match an expression
# here starting with "pota"
query <- spq_init() |>
  spq_prefix(prefixes = c(dct = "http://purl.org/dc/terms/")) |>
  spq_add(spq('?lexemeId dct:language wd:Q1860')) |>
  spq_mutate(lemma = wikibase::lemma(lexemeId)) |>
  spq_filter(str_detect(lemma, '^pota.*')) |>
  spq_select(lexemeId, lemma)