Title: | A 'Neo4J' Driver |
---|---|
Description: | A Modern and Flexible 'Neo4J' Driver, allowing you to query data on a 'Neo4J' server and handle the results in R. It's modern in the sense it provides a driver that can be easily integrated in a data analysis workflow, especially by providing an API working smoothly with other data analysis and graph packages. It's flexible in the way it returns the results, by trying to stay as close as possible to the way 'Neo4J' returns data. That way, you have the control over the way you will compute the results. At the same time, the result is not too complex, so that the "heavy lifting" of data wrangling is not left to the user. |
Authors: | Colin Fay [cre, aut] , ThinkR [cph], Neo4J [spn] |
Maintainer: | Colin Fay <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1.3 |
Built: | 2024-11-12 06:28:04 UTC |
Source: | https://github.com/neo4j-rstats/neo4r |
Call Neo4J API
call_neo4j(query, con, type = c("row", "graph"), output = c("r", "json"), include_stats = FALSE, include_meta = FALSE)
call_neo4j(query, con, type = c("row", "graph"), output = c("r", "json"), include_stats = FALSE, include_meta = FALSE)
query |
The cypher query |
con |
A NEO4JAPI connection object |
type |
Return the result as row or as graph |
output |
Use "json" if you want the output to be printed as JSON |
include_stats |
tShould the stats about the transaction be included? |
include_meta |
tShould the stats about the transaction be included? |
the result from the Neo4J Call
Extract nodes or relationships
extract_nodes(x) extract_relationships(x)
extract_nodes(x) extract_relationships(x)
x |
a result from Neo4J |
a tibble
Launch Neo4J Connection Pane
launch_con_pane(con)
launch_con_pane(con)
con |
a connection object |
an opened Connection Pane
Load a CSV to Neo4J
load_csv(on_load = "", con, url, header = TRUE, periodic_commit = 1000, as = "csv", type = c("row", "graph"), output = c("r", "json"), include_stats = TRUE, include_meta = FALSE)
load_csv(on_load = "", con, url, header = TRUE, periodic_commit = 1000, as = "csv", type = c("row", "graph"), output = c("r", "json"), include_stats = TRUE, include_meta = FALSE)
on_load |
the code to execute on load |
con |
A NEO4JAPI connection object |
url |
the url of the csv |
header |
does the csv have a header? |
periodic_commit |
the PERIODIC COMMIT cypher arg |
as |
the AS cypher arg |
type |
Return the result as row or as graph |
output |
Use "json" if you want the output to be printed as JSON |
include_stats |
tShould the stats about the transaction be included? |
include_meta |
tShould the stats about the transaction be included? |
a csv loaded to Neo4J
A Neo4J Connexion
neo4j_api
neo4j_api
An object of class R6ClassGenerator
of length 24.
A Neo4J Connexion
access
list url, user and password
ping
test your connexion
version
Neo4J version
get
Get a list of either relationship, labels,
get
Get a list of either relationship, labels,
get
Get a list of either relationship, labels,
get
Get a list of either relationship, labels,
get
Get a list of either relationship, labels,
url
list url, user and password
user
test your connexion
## Not run: con <- neo4j_api$new(url = "http://localhost:7474", user = "neo4j", password = "password") ## End(Not run)
## Not run: con <- neo4j_api$new(url = "http://localhost:7474", user = "neo4j", password = "password") ## End(Not run)
The Movie Graph
play_movies()
play_movies()
A character vector with the movie db
Read a cypher file
read_cypher(file)
read_cypher(file)
file |
the path to the cypher file |
a tibble with the queries
## Not run: read_cypher("random/create.cypher") ## End(Not run)
## Not run: read_cypher("random/create.cypher") ## End(Not run)
Send a cypher file to be executed
send_cypher(path, con, type = c("row", "graph"), output = c("r", "json"), include_stats = TRUE, meta = FALSE)
send_cypher(path, con, type = c("row", "graph"), output = c("r", "json"), include_stats = TRUE, meta = FALSE)
path |
the path to the cypher file |
con |
a connexion object created with neo4j_api$new() |
type |
the type of the format to query for (row or graph) |
output |
the printing method (r or json) |
include_stats |
whether of not to include stats |
meta |
whether of not to include meta info |
a cypher call
## Not run: send_cypher("random/create.cypher") path <- "data-raw/constraints.cypher" ## End(Not run)
## Not run: send_cypher("random/create.cypher") path <- "data-raw/constraints.cypher" ## End(Not run)
Unnest both relationships and nodes
unnest_graph(res)
unnest_graph(res)
res |
an api graph result |
a list of two unnested data.frames
Unnest a node data.frame
unnest_nodes(nodes_tbl, what = c("all", "label", "properties"))
unnest_nodes(nodes_tbl, what = c("all", "label", "properties"))
nodes_tbl |
the node table |
what |
what to unnest |
a new dataframe
Unnest a Relationships table
unnest_relationships(relationships_tbl)
unnest_relationships(relationships_tbl)
relationships_tbl |
a relationship table |
an unnested table
Please note that the properties will be converted to character if the class is not unique.
'vec_to_cypher()' creates a list, and 'vec_to_cypher_with_var()' creates a cypher call starting with a variable.
vec_to_cypher(vec, label) vec_to_cypher_with_var(vec, label, variable)
vec_to_cypher(vec, label) vec_to_cypher_with_var(vec, label, variable)
vec |
the vector |
label |
the label of each vector |
variable |
the variable to use (for 'vec_to_cypher()') |
This function can be used with small vectors you want to send to the server. It can for example be used this way : “' paste("MERGE", vec_to_cypher(iris[1, 1:3], "Species")) “' to create a cypher call.
a character vector
vec_to_cypher(iris[1, 1:3], "Species") vec_to_cypher_with_var(iris[1, 1:3], "Species", a)
vec_to_cypher(iris[1, 1:3], "Species") vec_to_cypher_with_var(iris[1, 1:3], "Species", a)