Skip to contents

Record a relationship of the form "subject -> predicate -> object", as defined by the Resource Description Framework (RDF), i.e. an RDF triple.


insertRelationship(x, ...)

# S4 method for DataPackage
  predicate = NA_character_,
  subjectType = NA_character_,
  objectTypes = NA_character_,
  dataTypeURIs = NA_character_



A DataPackage object


(Additional parameters)


The identifier of the subject of the relationship


A list of identifiers of the object of the relationships (a relationship is recorded for each objectID)


The IRI of the predicate of the relationship


the type to assign the subject, values can be 'uri', 'blank'


the types to assign the objects (cal be single value or list), each value can be 'uri', 'blank', or 'literal'


An RDF data type that specifies the type of the object


the updated DataPackage object


For use with DataONE, a best practice is to specify the subject and predicate as DataONE persistent identifiers ( If the objects are not known to DataONE, then local identifiers can be used, and these local identifiers may be promoted to DataONE PIDs when the package is uploaded to a DataONE member node. The predicate is typically an RDF property (as a IRI) from a schema supported by DataONE, i.e. "" If multiple values are specified for argument objectIDS, a relationship is created for each value in the list "objectIDs". IF a value is not specified for subjectType or objectType, then NA is assigned. Note that if these relationships are fetched via the getRelationships() function, and passed to the createFromTriples() function to initialize a ResourceMap object, the underlying redland package will assign appropriate values for subjects and objects. Note: This method updates the passed-in DataPackage object.


dp <- new("DataPackage")
# Create a relationship
dp <- insertRelationship(dp, "/Users/smith/scripts/genFields.R",
# Create a relationshp with the subject as a blank node with an automatically assigned blank 
# node id
dp <- insertRelationship(dp, subjectID=NA_character_, objectIDs="thing6", 
# Create a relationshp with the subject as a blank node with a user assigned blank node id
dp <- insertRelationship(dp, subjectID="urn:uuid:bc9e160e-ca21-47d5-871b-4a4820fe4451", 
      objectIDs="thing7", predicate="")
# Create multiple relationships with the same subject, predicate, but different objects
dp <- insertRelationship(dp, subjectID="urn:uuid:95055dc1-b2a0-4a00-bdc2-05c16d048ca2", 
      objectIDs=c("thing4", "thing5"), predicate="")
# Create multiple relationships with subject and object types specified
dp <- insertRelationship(dp, subjectID="", 
    objectIDs="", predicate="",
                   subjectType="uri", objectType="literal")