| Title: | 'RDF' and 'SPARQL' for R using 'Oxigraph' |
| Version: | 0.1.0 |
| Description: | Provides 'RDF' storage and 'SPARQL' 1.1 query capabilities by wrapping the 'Oxigraph' graph database library https://github.com/oxigraph/oxigraph. Supports in-memory and persistent ('RocksDB') storage, multiple 'RDF' serialization formats ('Turtle', 'N-Triples', 'RDF-XML', 'N-Quads', 'TriG'), and full 'SPARQL' 1.1 Query and Update support. Built using the 'extendr' framework for 'Rust'-R bindings. |
| License: | MIT + file LICENSE |
| URL: | https://github.com/cboettig/roxigraph |
| BugReports: | https://github.com/cboettig/roxigraph/issues |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.3 |
| Config/rextendr/version: | 0.4.2 |
| SystemRequirements: | Cargo (Rust's package manager), rustc >= 1.65.0, libclang-dev (for RocksDB bindings) |
| Depends: | R (≥ 4.2) |
| Suggests: | testthat (≥ 3.0.0), knitr, rmarkdown, spelling |
| Config/testthat/edition: | 3 |
| VignetteBuilder: | knitr |
| Language: | en-US |
| NeedsCompilation: | yes |
| Packaged: | 2026-02-01 01:45:29 UTC; cboettig |
| Author: | Carl Boettiger |
| Maintainer: | Carl Boettiger <cboettig@gmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-02-05 12:30:02 UTC |
roxigraph: RDF and SPARQL for R
Description
Provides RDF storage and SPARQL 1.1 query capabilities by wrapping the 'Oxigraph' graph database library. Supports in-memory and persistent ('RocksDB') storage, multiple RDF serialization formats, and full SPARQL 1.1 Query and Update support.
Main Functions
-
rdf_store: Create an RDF store -
rdf_load: Load RDF data -
sparql_query: Execute SPARQL queries -
sparql_update: Execute SPARQL updates -
rdf_serialize: Serialize RDF data
Author(s)
Maintainer: Carl Boettiger cboettig@gmail.com (ORCID)
Authors:
Authors of the dependency Rust crates (see inst/AUTHORS file)
Other contributors:
Oxigraph Contributors (Oxigraph Rust library) [copyright holder]
See Also
Useful links:
Report bugs at https://github.com/cboettig/roxigraph/issues
Add a Triple
Description
Adds a single triple to the store.
Usage
rdf_add(store, subject, predicate, object, graph = NULL)
Arguments
store |
An RDF store handle |
subject |
Subject IRI (e.g., |
predicate |
Predicate IRI (e.g., |
object |
Object: IRI, blank node, or literal (e.g., '"value"') |
graph |
Optional named graph IRI |
Value
Invisibly returns NULL
Examples
store <- rdf_store()
rdf_add(store, "<http://example.org/s>", "<http://example.org/p>", '"hello"')
rdf_size(store)
Load RDF Data
Description
Loads RDF data into the store from a string.
Usage
rdf_load(store, data, format = "turtle", base_iri = NULL)
Arguments
store |
An RDF store handle |
data |
RDF data as a character string |
format |
RDF format: "turtle", "ntriples", "rdfxml", "nquads", or "trig" |
base_iri |
Optional base IRI for resolving relative URIs |
Value
Invisibly returns NULL
Examples
store <- rdf_store()
rdf_load(store, '<http://example.org/s> <http://example.org/p> "value" .', format = "ntriples")
Load RDF from File
Description
Loads RDF data into the store from a file.
Usage
rdf_load_file(store, file, format = NULL, base_iri = NULL)
Arguments
store |
An RDF store handle |
file |
Path to the RDF file |
format |
RDF format. If NULL, guessed from file extension. |
base_iri |
Optional base IRI for resolving relative URIs |
Value
Invisibly returns NULL
Examples
store <- rdf_store()
# Create a temporary RDF file
tmp <- tempfile(fileext = ".nt")
writeLines('<http://example.org/s> <http://example.org/p> "value" .', tmp)
rdf_load_file(store, tmp)
rdf_size(store)
Remove a Triple
Description
Removes a single triple from the store.
Usage
rdf_remove(store, subject, predicate, object, graph = NULL)
Arguments
store |
An RDF store handle |
subject |
Subject IRI or blank node |
predicate |
Predicate IRI |
object |
Object: IRI, blank node, or literal |
graph |
Optional named graph IRI |
Value
Invisibly returns NULL
Examples
store <- rdf_store()
rdf_add(store, "<http://example.org/s>", "<http://example.org/p>", '"hello"')
rdf_remove(store, "<http://example.org/s>", "<http://example.org/p>", '"hello"')
rdf_size(store)
Serialize RDF Data
Description
Serializes the store contents to a string.
Usage
rdf_serialize(store, format = "turtle")
Arguments
store |
An RDF store handle |
format |
RDF format: "turtle", "ntriples", "rdfxml", "nquads", or "trig" |
Value
The serialized RDF data as a character string
Examples
store <- rdf_store()
rdf_load(store, '<http://example.org/s> <http://example.org/p> "value" .', format = "ntriples")
rdf_serialize(store, format = "turtle")
Get Store Size
Description
Returns the number of quads (triples) in the store.
Usage
rdf_size(store)
Arguments
store |
An RDF store handle |
Value
The number of quads as an integer
Examples
store <- rdf_store()
rdf_size(store)
Create an RDF Store
Description
Creates a new RDF store, either in-memory or backed by persistent storage.
Usage
rdf_store(path = NULL)
Arguments
path |
Optional path for persistent storage. If NULL (default), creates an in-memory store. |
Value
An RDF store handle (integer)
Examples
# In-memory store
store <- rdf_store()
# Persistent store (not supported on Windows)
if (.Platform$OS.type != "windows") {
store <- rdf_store(file.path(tempdir(), "my_store"))
}
Serialize the store contents to a string
Description
Serialize the store contents to a string
Usage
rdf_store_dump(store_idx, format)
Arguments
store_idx |
Store index |
format |
RDF format: "turtle", "ntriples", "rdfxml", "nquads", "trig" |
Value
The serialized RDF data
Examples
store <- rdf_store_new()
rdf_store_load(store, '<http://example.org/s> <http://example.org/p> "v" .', "ntriples", NULL)
rdf_store_dump(store, "turtle")
Insert a triple into the store
Description
Insert a triple into the store
Usage
rdf_store_insert(store_idx, subject, predicate, object, graph)
Arguments
store_idx |
Store index |
subject |
Subject IRI (e.g., |
predicate |
Predicate IRI (e.g., |
object |
Object (IRI, blank node, or literal with quotes e.g., "\"value\"") |
graph |
Optional graph name IRI |
Value
No return value, called for side effects (inserting triples into the store)
Examples
store <- rdf_store_new()
rdf_store_insert(store, "<http://example.org/s>", "<http://example.org/p>", '"val"', NULL)
Load RDF data into the store
Description
Load RDF data into the store
Usage
rdf_store_load(store_idx, data, format, base_iri)
Arguments
store_idx |
Store index |
data |
RDF data as a string |
format |
RDF format: "turtle", "ntriples", "rdfxml", "nquads", "trig" |
base_iri |
Optional base IRI for relative URIs |
Value
No return value, called for side effects (loading data into the store)
Examples
store <- rdf_store_new()
rdf_store_load(store, '<http://example.org/s> <http://example.org/p> "v" .', "ntriples", NULL)
Create a new in-memory RDF store
Description
Create a new in-memory RDF store
Usage
rdf_store_new()
Value
Store index (integer handle)
Arguments
This function takes no arguments.
Examples
store <- rdf_store_new()
rdf_store_size(store)
Open or create a persistent RDF store at the given path
Description
Open or create a persistent RDF store at the given path
Usage
rdf_store_open(path)
Arguments
path |
Path to the store directory |
Value
Store index (integer handle)
Examples
if (.Platform$OS.type != "windows") {
store <- rdf_store_open(file.path(tempdir(), "roxigraph_test"))
}
Execute a SPARQL query and return results as a data frame
Description
Execute a SPARQL query and return results as a data frame
Usage
rdf_store_query(store_idx, query)
Arguments
store_idx |
Store index |
query |
SPARQL query string |
Value
Query results as a data frame (for SELECT) or logical (for ASK)
Examples
store <- rdf_store_new()
rdf_store_load(store, '<http://example.org/s> <http://example.org/p> "v" .', "ntriples", NULL)
rdf_store_query(store, "SELECT * WHERE { ?s ?p ?o }")
Remove a triple from the store
Description
Remove a triple from the store
Usage
rdf_store_remove(store_idx, subject, predicate, object, graph)
Arguments
store_idx |
Store index |
subject |
Subject IRI or blank node |
predicate |
Predicate IRI |
object |
Object |
graph |
Optional graph name IRI |
Value
No return value, called for side effects (removing triples from the store)
Examples
store <- rdf_store_new()
rdf_store_insert(store, "<http://example.org/s>", "<http://example.org/p>", '"val"', NULL)
rdf_store_remove(store, "<http://example.org/s>", "<http://example.org/p>", '"val"', NULL)
Get the number of quads in the store
Description
Get the number of quads in the store
Usage
rdf_store_size(store_idx)
Arguments
store_idx |
Store index |
Value
The number of quads
Examples
store <- rdf_store_new()
rdf_store_size(store)
Execute a SPARQL UPDATE query
Description
Execute a SPARQL UPDATE query
Usage
rdf_store_update(store_idx, update)
Arguments
store_idx |
Store index |
update |
SPARQL UPDATE query string |
Value
No return value, called for side effects (executing SPARQL UPDATE queries)
Examples
store <- rdf_store_new()
rdf_store_update(store, "INSERT DATA { <http://example.org/s> <http://example.org/p> 'val' }")
Execute a SPARQL Query
Description
Executes a SPARQL query against the RDF store.
Usage
sparql_query(store, query)
Arguments
store |
An RDF store handle |
query |
A SPARQL query string |
Value
For SELECT queries, a data.frame with results. For ASK queries, a logical. For CONSTRUCT/DESCRIBE queries, a data.frame with subject, predicate, object columns.
Examples
store <- rdf_store()
rdf_load(store, '<http://example.org/s> <http://example.org/p> "hello" .', format = "ntriples")
sparql_query(store, "SELECT * WHERE { ?s ?p ?o }")
Execute SPARQL Update
Description
Executes a SPARQL UPDATE query to modify the store.
Usage
sparql_update(store, update)
Arguments
store |
An RDF store handle |
update |
A SPARQL UPDATE query string |
Value
Invisibly returns NULL
Examples
store <- rdf_store()
sparql_update(store, "INSERT DATA { <http://example.org/s> <http://example.org/p> 'value' }")