Skip to contents

Select (and create) particular variables

Usage

spq_select(.query = NULL, ..., .spq_duplicate = NULL)

Arguments

.query

a list with elements of the query

...

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

.spq_duplicate

How to handle duplicates: keep them (NULL), eliminate (distinct) or reduce them (reduced, advanced usage).

Value

A query object

Examples


spq_init() |>
  spq_prefix(prefixes = c(dct = "http://purl.org/dc/terms/")) |>
  spq_add(spq('?lexemeId dct:language wd:Q1860')) |>
  spq_add(spq("?lexemeId wikibase:lemma ?lemma")) |>
  spq_filter(str_detect(lemma, '^pota.*')) |>
  spq_select(- lemma)
#> PREFIX dct: <http://purl.org/dc/terms/>
#> PREFIX wd: <http://www.wikidata.org/entity/>
#> PREFIX wikibase: <http://wikiba.se/ontology#>
#> SELECT ?lexemeId
#> WHERE {
#> 
#> ?lexemeId dct:language wd:Q1860.
#> ?lexemeId wikibase:lemma ?lemma.
#> FILTER(REGEX(?lemma,"^pota.*"))
#> }
#> 

spq_init() |>
  spq_prefix(prefixes = c(dct = "http://purl.org/dc/terms/")) |>
  spq_add(spq('?lexemeId dct:language wd:Q1860')) |>
  spq_add(spq("?lexemeId wikibase:lemma ?lemma")) |>
  spq_filter(str_detect(lemma, '^pota.*')) |>
  spq_select(lemma)
#> PREFIX dct: <http://purl.org/dc/terms/>
#> PREFIX wd: <http://www.wikidata.org/entity/>
#> PREFIX wikibase: <http://wikiba.se/ontology#>
#> SELECT ?lemma
#> WHERE {
#> 
#> ?lexemeId dct:language wd:Q1860.
#> ?lexemeId wikibase:lemma ?lemma.
#> FILTER(REGEX(?lemma,"^pota.*"))
#> }
#>