Cypher Queries to Data Frames

Share:

Description

Retrieve Cypher query results as a data frame.

Usage

1
cypher(graph, query, ...)

Arguments

graph

A graph object.

query

A character string.

...

A named list. Parameters to pass to the query in the form key = value, if applicable.

Details

If returning data, you can only query for tabular results. That is, you can't return node or relationship entities. See cypherToList for returning non-tabular data.

Value

A data.frame.

See Also

cypherToList

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
## Not run: 
graph = startGraph("http://localhost:7474/db/data/")
clear(graph)

alice = createNode(graph, "Person", name = "Alice", age = 23)
bob = createNode(graph, "Person", name = "Bob", age = 22)
charles = createNode(graph, "Person", name = "Charles", age = 25)
david = createNode(graph, "Person", name = "David", age = 20)

createRel(alice, "KNOWS", bob)
createRel(alice, "KNOWS", charles)
createRel(charles, "KNOWS", david)

cypher(graph, "MATCH n RETURN n.name, n.age")

query = "MATCH n WHERE n.age < {age} RETURN n.name, n.age"
cypher(graph, query, age = 24)

query = "MATCH n WHERE n.name IN {names} RETURN n.name, n.age"
names = c("Alice", "Charles")
cypher(graph, query, names = names)

query = "MATCH n WHERE n.age > {age1} AND n.age < {age2} RETURN n.name"
cypher(graph, query, age1=22, age2=30)

params = list(age1=22, age2=30)
cypher(graph, query, params)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.