edgify_cols: edgify_cols

Description Usage Arguments Value Examples

Description

Write edges among two or more types of nodes described in a data.frame to Neo4j.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
edgify_cols(
  df,
  a.col.name,
  b.col.names,
  a.unique.property = a.col.name,
  b.unique.properties = "Name",
  relationships_in_cypher = "--",
  a.node.label = a.col.name,
  b.node.labels = b.col.names,
  neo.import.dir = neo.import.dir,
  periodic_commit = "10000"
)

Arguments

df

A data.frame

a.col.name

col with unique ID for a

b.col.names

can be a character string or vector - cols with unique IDs for b

a.unique.property

The name of a unique property for nodes in the first column. Eg. "Client_ID". Use the name of the unique property exactly as you defined it when you created the nodes.

relationships_in_cypher

The relationships to create between the nodes, written in Cypher code. Relationships can be directed or undirected, and they can be labeled or unlabeled. Cypher is not case-sensitive.

  • For directed relationships, the head of the arrow indicates direction: eg. if A LIKES B, use "-:Likes->" # NOTE: brackets aren't displaying properly. Everything between the dashes should be enclosed in brackets. eg. if B LIKES A, use "<-:Likes-" eg. to define an unlabeled directed relationship from A towards B, use "–>"

  • For mutual or undirected relationships, no arrow is needed. eg. if A and B have met, use "-:Has_Met-"

a.node.label
b.node.labels
neo.import.dir

The directory location of the Neo4j import folder.

periodic_commit

Default is "10000" rows in memory at a time.

b.unique.property

The name of a unique property for nodes in the second column. Eg. "Client_ID"

Value

The function writes a .csv file in your Neo4j database import directory, then loads the data to Neo4j. Once done, the .csv file is no longer needed, and it will be overwritten the next time the function is used.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
edgify_cols(
   df = staff2,
   a.col.name = "userPrincipalName", 
   b.col.names = c("Business_Unit", "Group", "Department", "City", "Office"), # plural
   a.unique.property = a.col.name,
   b.unique.properties = "Name", # pl
   relationships_in_cypher = "-[:Works_In]->", # can be plural but defaults to unnamed relationship. If rels from a to all other are the same, enter it once.
   a.node.label = "Person", # default
   b.node.labels = b.col.names, # default, pl
   neo.import.dir,
   periodic_commit = "100000"
)

brendan-newlon/df2neo4j documentation built on Sept. 19, 2020, 5:44 a.m.