A SPARQL Client for R

Provides a client for running SPARQL queries directly from R. SPARQL (short for SPARQL Protocol and RDF Query Language) is a query language used to retrieve and manipulate data stored in RDF (Resource Description Framework) format.


sparqlr

A SPARQL client for R.

sparqlr is an R library that allows running SPARQL queries directly from R. SPARQL (short for SPARQL Protocol and RDF Query Language) is a query language used to retrieve and manipulate data stored in RDF (Resource Description Framework) format.


Installation

Installing from CRAN

The latest stable version of the package can be installed from CRAN. Start an R session, then run:

install.packages("sparqlr")

Installing from GitHub

The latest development (unstable) version of the package can be found on GitHub. Start an R session, then run:

remotes::install_github("sib-swiss/sparqlr")

Note: running the above command requires you to have the remotes R package installed on your machine.
Should that not already be the case, you can install it with the command: install.packages("remotes").


Usage examples

Running a simple SELECT query:

query <- "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?message
WHERE{
    wd:Q131303 rdfs:label ?message
    FILTER( LANG( ?message ) = 'en' )
}
"

sparql_select(
  endpoint = "https://query.wikidata.org/sparql",
  query = query 
)

Running a simple CONSTRUCT query:

query <- "CONSTRUCT {
      wd:Q166794  wdt:P2974  ?habitat  .
}
WHERE {
    wd:Q166794  ?p         ?o        ;
                wdt:P2974  ?habitat  .
}
"

sparql_construct(
  endpoint = "https://query.wikidata.org/sparql",
  query = query 
)

Running a simple DESCRIBE query:

query <- "DESCRIBE wd:Q166794
LIMIT 50
"

sparql_describe(
  endpoint = "https://query.wikidata.org/sparql",
  query = query 
)

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("sparqlr")

0.1.0 by Robin Engler, 6 months ago


https://github.com/sib-swiss/sparqlr


Report a bug at https://github.com/sib-swiss/sparqlr/issues


Browse source code at https://github.com/cran/sparqlr


Authors: Marco Pagni [aut] , Robin Engler [aut, cre] (ORCID: , SIB Swiss Institute of Bioinformatics [cph]


Documentation:   PDF Manual  


GPL-3 license


Imports dplyr, httr2, purrr, rlang, stringr, tibble, tidyr

Suggests knitr, lintr, rcmdcheck, rmarkdown, styler, testthat


See at CRAN