The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

roxigraph

R-CMD-check CRAN status r-universe License: MIT

roxigraph provides RDF storage and SPARQL 1.1 query capabilities for R by wrapping the Oxigraph graph database library. Built using the extendr framework for high-performance Rust-R bindings.

Features

Installation

Install pre-built binaries from r-universe:

install.packages("roxigraph", repos = c("https://cboettig.r-universe.dev", "https://cloud.r-project.org"))

Linux (Ubuntu)

For binary installation on Ubuntu (no Rust required):

# Set up r-universe binary repo for Linux
repo <- sprintf(
  "https://cboettig.r-universe.dev/bin/linux/noble-%s/%s/",
  R.version$arch, substr(getRversion(), 1, 3)
)
install.packages("roxigraph", repos = c(repo, "https://cloud.r-project.org"))

From source (requires Rust)

# install.packages("pak")
pak::pak("cboettig/roxigraph")

Building from source requires: - Rust toolchain (rustc >= 1.65, cargo) - libclang-dev (for RocksDB bindings on Linux)

On Ubuntu/Debian:

# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Install libclang
sudo apt-get install libclang-dev

Quick Start

library(roxigraph)

# Create an in-memory store
store <- rdf_store()

# Load some RDF data (Turtle format)
rdf_load(store, '
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ex: <http://example.org/> .

ex:alice foaf:name "Alice" ;
         foaf:knows ex:bob .
ex:bob foaf:name "Bob" .
', format = "turtle")

# Query with SPARQL
sparql_query(store, "
  PREFIX foaf: <http://xmlns.com/foaf/0.1/>
  SELECT ?name WHERE { ?person foaf:name ?name }
  ORDER BY ?name
")
#>      name
#> 1 "Alice"
#> 2   "Bob"

# Check store size
rdf_size(store)
#> [1] 3

Persistent Storage

For data that should persist across R sessions:

# Create a persistent store
store <- rdf_store("/path/to/my/database")

# Data is automatically persisted to disk
rdf_load(store, data, format = "turtle")

SPARQL Update

Modify your data using SPARQL Update:

store <- rdf_store()

# Insert data
sparql_update(store, "
  INSERT DATA {
    <http://example.org/alice> <http://xmlns.com/foaf/0.1/name> 'Alice' .
  }
")

# Query the inserted data
sparql_query(store, "SELECT * WHERE { ?s ?p ?o }")
#>         o                                p                          s
#> 1 "Alice" <http://xmlns.com/foaf/0.1/name> <http://example.org/alice>

Serialization

Export your RDF data to various formats:

store <- rdf_store()
rdf_load(store, '<http://ex.org/s> <http://ex.org/p> "hello" .', format = "ntriples")

# Serialize to N-Quads
cat(rdf_serialize(store, format = "nquads"))
#> <http://ex.org/s> <http://ex.org/p> "hello" .

Learn More

License

MIT © Carl Boettiger

Oxigraph is dual-licensed under MIT/Apache-2.0.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.