dataset_to_triples: Dataset to triples (three columns or N-Triples)

View source: R/dataset_to_triples.R

dataset_to_triplesR Documentation

Dataset to triples (three columns or N-Triples)

Description

Converts a dataset to RDF-style triples with subject, predicate, and object columns. Supports semantic expansion via variable metadata.

Usage

dataset_to_triples(x, idcol = NULL, expand_uri = TRUE, format = "data.frame")

Arguments

x

A dataset_df or data.frame.

idcol

Name or index of the subject column. If NULL, defaults to "rowid" or rownames.

expand_uri

Logical; if TRUE, expands URIs using namespaces and definitions.

format

Output format: "data.frame" (default) or "nt" for N-Triples.

Details

For publishing examples, a minimal serverless scaffold is provided at https://github.com/dataobservatory-eu/dataset-template, which shows how to host CSV + RDF serialisations on GitHub Pages without any server setup.

Value

Either a data.frame with columns s, p, and o, or a character vector of N-Triple lines.

Note

A simple, serverless scaffolding for publishing dataset_df objects on the web (with HTML + RDF exports) is available at https://github.com/dataobservatory-eu/dataset-template.

Examples

# A minimal example with just rowid and geo
data("gdp", package = "dataset")
small_geo <- dataset_df(
  geo = defined(
    gdp$geo[1:3],
    label = "Geopolitical entity",
    concept = "http://example.com/prop/geo",
    namespace = "https://dd.eionet.europa.eu/vocabulary/eurostat/geo/$1"
  )
)

# View as triple table
dataset_to_triples(small_geo)

# View as N-Triples
dataset_to_triples(small_geo, format = "nt")

dataset documentation built on Nov. 16, 2025, 5:06 p.m.