我正在尝试使用该RNeo4j
包在 R 中创建一个图形数据库。基本上,@Nicole White 在这里展示的是我试图完全通过 RStudio IDE 实现的目标。我已将数据读入 R 并使用lubridate
包对日期字段进行了一些基本的管理。此后,我将关注 Nicole 在此处为hflights
数据集显示的内容。这是相关代码:
query="
CREATE (complaint:Complaint {id: TOINT({ComplaintID})})
SET complaint.day = ({ComplaintDay}),
complaint.month = ({ComplaintMonth}),
complaint.year = ({ComplaintYear})
MERGE (company:Company {name:{CompanyName}})
MERGE (response:Response {name:{Companyresponsetoconsumer}})
CREATE (complaint) -[:AGAINST]-> (company)
CREATE (response) -[r:TO]-> (complaint)
SET r.timely = CASE {Timelyresponse} WHEN 'Yes' THEN true ELSE false END,
r.disputed = CASE {Consumerdisputed} WHEN 'Yes' THEN true ELSE false END
"
tx = newTransaction(graph)
for(i in 1:nrow(complaint)) {
row = complaint[i, ]
appendCypher(tx, query,
ComplaintID=complaint$Complaint.ID,
ComplaintDay=complaint$Complaint.Day,
ComplaintMonth=complaint$Complaint.Month,
ComplaintYear=complaint$Complaint.Year,
CompanyName=complaint$Company,
Companyresponsetoconsumer=complaint$Company.response.to.consumer,
Timelyresponse=complaint$Timely.response.,
Consumerdisputed=complaint$Consumer.disputed.)
}
commit(tx)
summary(graph)
但是,当我运行for
循环时,出现以下错误:
Error in appendCypher.transaction(tx, query, ComplaintID =
complaint$Complaint.ID, :
Neo.ClientError.Statement.TypeError
Expected a String or Number, got: List(1913026, 99413, 1420666, 1139505, 850511, 211452, 299293, 967118, 1342525, 218870, 936088, 1577433, 396460, 976892, 1713179, 985796, 1274906, 1524883, 549683, 375379, 2083877, 1804301, 568928, 643695, 2013448, 1822596, 1054868, 1058533, 1972148, 1053127, 1546919, 1974786, 1386150, 558306, 2029982, 1812827, 2112000, 1279031, 1729024, 811685, 423229, 211371, 550247, 1837165, 589977, 363963, 773706, 1422738, 362615, 1918434, 31932, 101419, 109634, 799711, 568707, 425802, 1354727, 905367, 433560, 950090, 1615178, 1085081, 1842311, 55218, 82206, 8990, 1716274, 1199075, 315208, 976080, 1747751, 1424814, 757803, 61250, 592018, 974917, 2046258, 1901776, 123518, 1362552, 257123, 1212622, 1663172, 1200587, 84365, 358901, 1920239, 691273, 226122, 36142, 1615314, 809300, 1987176, 596079, 1619346, 1261257, 984128, 793228, 173250, 249440, 192131, 1759419, 1394747, 1316550, 1890080, 862502, 1192961, 506058, 2000389,
状态码表明该complaint$Complaint.ID
类型可能不受支持。但是不会TOINT
管这个吗?
请在这里提供一些帮助。