Created
May 19, 2016 07:15
-
-
Save kkruups/17f96fa12d6b81124a0f4f331c2c4e67 to your computer and use it in GitHub Desktop.
Rscript: RNeo4j getPath return values indicate file.info(x) error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sys.setenv(LANG = "en") | |
library(RNeo4j) | |
library(httr) | |
#Sys.getlocale() | |
#Sys.setlocale(categories = "LC_ALL" , locale = "Japanese_Japan.932" ) | |
#Sys.setlocale( locale = "en_utf8" ) | |
#Sys.setenv(LANG = "en") | |
#set_config(verbose()) | |
set_config(config(noproxy = "localhost")) | |
#start graphdb (returns a graph object which allows connection to db) | |
graph = startGraph("http://localhost:7474/db/data/") | |
clear(graph, input=FALSE) | |
#Create Nodes | |
nicole = createNode(graph, "Human", name="Nicole", age=24) | |
greta = createNode(graph, "Human", name="Greta", age=24) | |
kenny = createNode(graph, "Human", name="Kenny", age=27) | |
shannon = createNode(graph, "Human", name="Shannon", age=23) | |
#Create relationships | |
r1 = createRel(greta, "FRIENDED", nicole, weight=7) | |
r2 = createRel(nicole, "FRIENDED", kenny, weight=1) | |
r3 = createRel(kenny, "FRIENDED", shannon, weight=3) | |
r4 = createRel(nicole, "FRIENDED", shannon, weight=5) | |
#cypher query | |
query1 = " | |
MATCH (nicole:Human)-[r:FRIENDED]->(p:Human) | |
WHERE nicole.name = 'Nicole' | |
RETURN nicole.name, r.weight, p.name | |
" | |
#execute query (returns a data frame object) | |
query_result <- cypher(graph, query1) | |
query2 = " | |
MATCH p = (h1:Human)-[:FRIENDED*..4]->(h2:Human) | |
WHERE h1.name = 'Nicole' AND h2.name = 'Shannon' | |
RETURN p | |
" | |
#Add some space newlines to make output clear | |
cat("\n\n") | |
cat("XXXX Correct str execution List for Comparison XXXXX\n") | |
#Compare with ordinary list behavior | |
verifyList <- list(c(1,2,4,5), function(x){ print(x) }) | |
str(verifyList) | |
str(verifyList[[1]]) | |
str(verifyList[[2]]) | |
#Add some space newlines to make output clear | |
cat("\n\n") | |
cat("XXXXX Error:Unexpected behavior Below str(p) XXXXX\n") | |
p = getPaths(graph, query2) | |
#Error occurs here | |
str(p) | |
#str(p[[1]]) | |
#str(p[[2]]$length) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Commandline execution (on windows, set path to rscript location set Path = %Path%;c:\path_to_rscript_executable)
c:\mypath>rscript.exe filename.R