Learn R Programming

RNeo4j (version 1.6.4)

cypher: Cypher Queries to Data Frames

Description

Retrieve Cypher query results as a data frame.

Usage

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.

Value

A data.frame.

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.

See Also

cypherToList

Examples

Run this code
## 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)

Run the code above in your browser using DataLab