Learn R Programming

WikidataQueryServiceR (version 0.1.1)

query_wikidata: Send one or more SPARQL queries to WDQS

Description

Makes a GET request to Wikidata Query Service SPARQL endpoint.

Usage

query_wikidata(sparql_query, format = c("simple", "smart"), ...)

Arguments

sparql_query

SPARQL query (can be a vector of queries)

format

"simple" uses CSV and returns pure character data frame, while "smart" fetches JSON-formatted data and returns a data frame with datetime columns converted to POSIXlt

...

Additional parameters to supply to httr::GET()

Value

A data.frame

Examples

Run this code
# NOT RUN {
# R's versions and release dates:
sparql_query <- 'SELECT DISTINCT
  ?softwareVersion ?publicationDate
WHERE {
  BIND(wd:Q206904 AS ?R)
  ?R p:P348 [
    ps:P348 ?softwareVersion;
    pq:P577 ?publicationDate
  ] .
}'
query_wikidata(sparql_query)

# }
# NOT RUN {
# "smart" format converts all datetime columns to POSIXlt
query_wikidata(sparql_query, format = "smart")
# }

Run the code above in your browser using DataLab