Learn R Programming

rdflib (version 0.2.9)

rdf_query: Perform a SPARQL Query

Description

Perform a SPARQL Query

Usage

rdf_query(rdf, query, data.frame = TRUE, ...)

Value

a data.frame of all query results (default.) Columns will be named according to variable names in the SPARQL query. Returned object values will be coerced to match the corresponding R type to any associated datatype URI, if provided. If a column would result in mixed classes (e.g. strings and numerics), all types in the column will be coerced to character strings. If data.frame

is false, results will be returned as a list with each element typed by its data URI.

Arguments

rdf

an rdf object (e.g. from rdf_parse)

query

a SPARQL query, as text string

data.frame

logical, should the results be returned as a data.frame?

...

additional arguments to a redland initialize-Query

Examples

Run this code
doc <- system.file("extdata", "dc.rdf", package="redland")

sparql <-
'PREFIX dc: 
 SELECT ?a ?c
 WHERE { ?a dc:creator ?c . }'

rdf <- rdf_parse(doc)
rdf_query(rdf, sparql)

Run the code above in your browser using DataLab