Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result.
Source:R/spq_perform.R
spq_perform.Rd
Assemble query parts into a sparql query and send it to endpoint to get a tibble as a result.
Usage
spq_perform(
.query,
endpoint = lifecycle::deprecated(),
user_agent = lifecycle::deprecated(),
max_tries = lifecycle::deprecated(),
max_seconds = lifecycle::deprecated(),
timeout = lifecycle::deprecated(),
request_type = lifecycle::deprecated(),
dry_run = FALSE,
replace_prefixes = FALSE
)
Arguments
- .query
a list with elements of the query
- endpoint
a string or url corresponding to a SPARQL endpoint. Defaults to "Wikidata"
- user_agent
- max_tries, max_seconds
Cap the maximal number of attemps with
max_tries
or the total elapsed time from the first request withmax_seconds
.- timeout
maximum number of seconds to wait (
httr2::req_timeout()
).- request_type
a string indicating how the query should be sent: in the URL (
url
, default, most common) or as a body form (body-form
).- dry_run
Boolean indicating whether to return the output of
httr2::req_dry_run()
rather than ofhttr2::req_perform()
. Useful for debugging.- replace_prefixes
Boolean indicating whether to replace used prefixes in the results table, for instance making, for instance "http://www.wikidata.org/entity/" "wd:".
Request control
Control the way the query is performed via the control_request
argument of spq_init()
.
This way you can create a basic spq object with all the correct options
corresponding to the SPARQL service you are using, and then use it as
the basis of all your subsequent glitter pipelines.
Examples
# \dontrun{
spq_init() %>%
spq_add(.subject="?city",.verb="wdt:P31",.object="wd:Q515") %>%
spq_add(.subject="?city",.verb="wdt:P1082",.object="?pop") %>%
spq_label(city) %>%
spq_head(n=5) %>%
spq_perform()
#> # A tibble: 5 × 3
#> city pop city_label
#> <chr> <chr> <chr>
#> 1 http://www.wikidata.org/entity/Q1519 1483000 Abu Dhabi
#> 2 http://www.wikidata.org/entity/Q1524 643452 Athens
#> 3 http://www.wikidata.org/entity/Q1533 2245744 Caracas
#> 4 http://www.wikidata.org/entity/Q1538 5945000 Pune
#> 5 http://www.wikidata.org/entity/Q1555 1213651 Guatemala City
# }