Skip to contents

Create and modify variables in the results

Usage

spq_mutate(
  .query,
  ...,
  .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

# common name of a plant species in different languages
# the triplet pattern "wd:Q331676 wdt:P1843 ?statement"
# creates the variable statement
# hence our writing it in reverse within the spq_mutate() function
spq_init() %>%
spq_mutate(statement = wdt::P1843(wd::Q331676)) %>%
spq_mutate(lang = lang(statement))