RDF Library Bindings in R

Provides methods to parse, query and serialize information stored in the Resource Description Framework (RDF). RDF is described at < http://www.w3.org/TR/rdf-primer>. This package supports RDF by implementing an R interface to the Redland RDF C library, described at < http://librdf.org/docs/api/index.html>. In brief, RDF provides a structured graph consisting of Statements composed of Subject, Predicate, and Object Nodes.

The R package redland provides methods to create, query and write information stored in the Resource Description Framework (RDF). An introduction to RDF can be found at http://www.w3.org/TR/rdf-primer. In brief, RDF provides a structured graph consisting of Statements composed of Subject, Predicate, and Object Nodes.

This package is implemented as R scripts that provide an R interface (aka "wrapper") to the Redland RDF C libraries that are described at http://librdf.org/docs/api/index.html. In this redland R wrapper, S4 classes are used to model RDF data structures. A redland::Statement is composed of redland::Nodes representing the subject, predicate, and object of each triple statement. Statements can be composed into a graph by adding them to a redland::Model, which in turn can be serialized and deserialized to RDF's text formats using redland::Serializer and redland::Parser, respectively.

See the redland_overview vignette for a brief example of usage.

The redland R package is now available from CRAN. Before the redland R package can be installed, the Redland C libraries may need to be installed, depending on the platform type you are installing to and whether or not you wish to install from source.

On Mac OS X, the binary build from CRAN can be installed without installing the Redland C libraries by typing the following commands in the R console:


The redland R package should be available for use at this point.

Alternatively, to install redland from source, please continue reading this section.

The required Redland C libraries can be installed with either Mac Ports package manager or the HomeBrew package manager. The HomeBrew package manager can be significantly faster to install but either one will work provided the directions shown below are followed.

You can check if you have MacPorts installed by entering the following command in a terminal window:

port version

If you are already using the MacPorts package manager, you can install redland with the following commands, otherwise, it is recommended that you skip to the next section Installing with HomeBrew. To install the redland R package with MacPorts, enter these commands at a terminal window:

sudo port install redland

Then enter these commands in the R console:

install.packages("redland", type="source")

Please note that the install.packages command specifies a "source" installation. Installing from source is only necessary if Macports is being used, and is not a requirement if Homebrew is used.

The redland R package should be available for use at this point

On Mac OS X you can use the package management system HomeBrew to install the necessary libraries. The HomeBrew software can be installed with the following command entered at a terminal window:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Once HomeBrew has been installed, you can then enter the following command to install the Redland C libraries:

brew install redland

Next, install the redland R package with these commands typed at the R console window:

install.packages("redland", type="source")

The redland R package should be available for use at this point.

For ubuntu, install the required Redland C libraies:

sudo apt-get update
sudo apt-get install librdf0 librdf0-dev

Then install the R packages from the R console:


For windows, the redland R package is distributed as a binary release, and it is not necessary to install any additional system libraries.

To install the R packages from the R console:


The redland library can be used for a wide variety of RDF parsing and creation tasks. Some examples are provided in the redland_overview vignette. As a quick start, here is an example that creates an RDF graph using an in-memory storage model, adds some triples, and then serializes the graph to disk.

# World is the redland mechanism for scoping models
world <- new("World")
# Storage provides a mechanism to store models; in-memory hashes are convenient for small models
storage <- new("Storage", world, "hashes", name="", options="hash-type='memory'")
# A model is a set of Statements, and is associated with a particular Storage instance
model <- new("Model", world=world, storage, options="")
# Add some Dublin Core properties to the model
dc <- "http://purl.org/dc/elements/1.1/"
stmt <- new("Statement", world=world, 
        subject="http://ropensci.org/", predicate=paste0(dc, "title"), object="ROpenSci")
addStatement(model, stmt)
stmt <- new("Statement", world=world, 
        subject="http://ropensci.org/", predicate=paste0(dc, "language"), object="en")
addStatement(model, stmt)
stmt <- new("Statement", world=world, 
        subject="http://ropensci.org/", predicate=paste0(dc, "license"), 
addStatement(model, stmt)
# Serialize the model to a TTL file
serializer <- new("Serializer", world, name="turtle", mimeType="text/turtle")
status <- setNameSpace(serializer, world, namespace="http://purl.org/dc/elements/1.1/", prefix="dc")  
filePath <- tempfile(pattern = "file", tmpdir = tempdir(), fileext = ".ttl")
status <- serializeToFile(serializer, world, model, filePath)

Work on this package was supported by NSF-ABI grant #1262458 to C. Gries, M. Jones, and S. Collins.


Version 1.0.17-8


  • For Mac OS X, binary installations no longer require Redland system libraries to be installed, as these libraries are now statically linked into the redland package shared library 'redland.so'.


  • Fixed an unresolved symbol problem with Windows 32 bit builds under R 3.3.0 (and gcc 4.9.3 tool chain)

Version 1.0.17-7


  • Unit tests have been updated to be compatible with the changes in the 'testthat' package that were made in development version testthat_0.11.0.9000, and will be released to CRAN on 4/4/2016. The updated unit tests pass with both the current version of testthat (0.11.0) and the new version (


  • Initial version (see help topic for 'redland', e.g. "?redland")

  • Includes API wrappers for corresponding Redland 1.0.17 C library


  • Classes Node, Statement, and Model for representing RDF

  • Classes Storage and World for managing collections of statements

  • Classes Parser and Serializer for for loading and saving models

  • classes Query and QueryResults for searching models using SPARQL

Reference manual

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


1.0.17-9 by Matthew B. Jones, 2 months ago

Report a bug at https://github.com/ropensci/redland-bindings/issues

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

Authors: Matthew B. Jones [aut, cre], Peter Slaughter [aut], Jeroen Ooms [aut], Carl Boettiger [aut], Scott Chamberlain [aut], David Beckett [cph], University of Bristol [cph], Regents of the University of California [cph]

Documentation:   PDF Manual  

Apache License 2.0 license

Imports roxygen2

Depends on methods

Suggests knitr, testthat, rmarkdown

System requirements: Mac OSX: redland (>= 1.0.14) ; Linux: librdf0 (>= 1.0.14), librdf0-dev (>= 1.0.14)

Imported by datapack.

See at CRAN