View source: R/Creation_Functions.R
createRelationship | R Documentation |
Create a single relationship with its property keys, passed as arguments, in a Neo4j database.
createRelationship(
connection,
started_node_label,
started_node_property,
started_node_property_value,
end_node_label,
end_node_property,
end_node_property_value,
relationship_label,
relationship_property_keys = NULL
)
connection |
The Neo4j connection object. |
started_node_label |
The started node label. |
started_node_property |
The started node property key name to be identified by. |
started_node_property_value |
The started node property key value to be found within. |
end_node_label |
The end node label. |
end_node_property |
The end node property key name to be identified by. |
end_node_property_value |
The end node property key value to be found within. |
relationship_label |
The relationship label. |
relationship_property_keys |
The relationship property keys, in the form of dataframe. |
The result from the Neo4j call.
## Not run:
#Get the dataframe of relationships to be created
relationships = prepareRelationshipsDataframeToCreate(wntmully,nodes)
#Create all nodes in the Neo4j database
for(row in 1:nrow(relationships)){
relationship_property_keys = relationships[row, !names(relationships) %in%
c("label", "V1 label", "V2 label", "V1", "V2")]
na_cells = which(is.na(relationship_property_keys))
names_not_na = names(relationship_property_keys)[-na_cells]
relationship_property_keys = as.data.frame(relationship_property_keys[,-na_cells])
colnames(relationship_property_keys) = names_not_na
createRelationship(connection, relationships[row,'V1_label'], 'name',
relationships[row,'V1'], relationships[row,'V2_label'],
'name', relationships[row,'V2'], relationships[row,'label'],
relationship_property_keys)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.