Tried to connect to neo4j
from R
Ran this:
install.packages('RCurl')
install.packages('RJSONIO')
library('bitops')
library('RCurl')
library('RJSONIO')
query <- function(querystring) {
h = basicTextGatherer()
curlPerform(url="http://localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query",
postfields=paste('query',curlEscape(querystring), sep='='),
writefunction = h$update,
verbose = FALSE
)
result <- fromJSON(h$value())
data <- data.frame(t(sapply(result$data, unlist)))
names(data) <- result.json$columns
data
}
Then I am running:
q<-"MATCH (p:Person) RETURN p.name"
data<-query(q)
But it is giving the error:
Error in query(q) : object 'result.json' not found
I have updated R studio to 0.98.501
and R is at R-3.1.0-snowleopard.pkg
. Why am I getting this error? Thanks!
Got this to work from a fork by Mark Needham
library('RCurl')
library('RJSONIO')
query <- function(querystring) {
h = basicTextGatherer()
curlPerform(url="http://localhost:7474/db/data/cypher",
postfields=paste('query',curlEscape(querystring), sep='='),
writefunction = h$update,
verbose = FALSE
)
result <- fromJSON(h$value())
data <- data.frame(t(sapply(result$data, unlist)))
names(data) <- result$columns
data
}
Then just ran:
data <- query("START n = node(*) RETURN COUNT(n) AS count")
Worked perfectly
Your query has a clear error:
MATCH (p:Person) RETURN a.name
You're matching a node called "p", and returning the name property on a node called "a".
Try this instead:
MATCH (p:Person) RETURN p.name
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.