MyNixOS website logo
Description

'RDF' and 'SPARQL' for R using 'Oxigraph'.

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.

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

  • 🚀 High Performance: Rust-powered RDF storage with RocksDB backend
  • 💾 Flexible Storage: In-memory or persistent on-disk databases
  • 📄 Multiple Formats: Turtle, N-Triples, RDF-XML, N-Quads, TriG
  • 🔍 Full SPARQL 1.1: Query and Update support

Installation

Windows / macOS (recommended)

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.

Metadata

Version

0.1.1

License

Unknown

Platforms (78)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    uefi
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-freebsd
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64-uefi
  • aarch64-windows
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-linux
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-uefi
  • x86_64-windows