Skip to contents

Label variables

Usage

spq_label(
  .query,
  ...,
  .required = FALSE,
  .languages = getOption("glitter.lang", "en$"),
  .overwrite = FALSE
)

Arguments

.query

a list with elements of the query

...

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

.required

whether the existence of a value for the triple is required or not (defaults to TRUE). If set to FALSE, then other triples in the query are returned even if this particular triple is missing)

.languages

Languages for which to query labels. Use NULL for removing restrictions on language (defined or not), "*" for any defined language. If you write "en" you can get labels for regional variants such as "en-GB". If you want results for "en" only, write "en$".

.overwrite

whether to replace variables with their labels. spq_select(blop) means you get both blop and blop_label. spq_select(blop, .overwrite = TRUE) means you get the label as blop, the "original" blop variable isn't returned.

Value

A query object

Details

spq_label() uses the property:

  • associated with the usual endpoint see usual_endpoints

  • the property indicated in spq_endpoint_info()

Example

spq_init() %>%
  spq_add("?mayor wdt:P31 ?species") %>%
# dog, cat or chicken
  spq_set(species = c('wd:Q144','wd:Q146', 'wd:Q780')) %>%
# who occupy the function
  spq_add("?mayor p:P39 ?node") %>%
# of mayor
  spq_add("?node ps:P39 wd:Q30185") %>%
# of some places
  spq_add("?node pq:P642 ?place") %>%
  spq_label(mayor, place, .languages = c("fr", "en", "de")) %>%
  spq_perform()