2017-03-08 6 views
0

RNeo4jパッケージを使用してRでグラフデータベースを作成しようとしています。基本的に@Nicloe Whiteがhereを示しているのは、私がRStudio IDEを通して完全に達成しようとしていることです。私はdataをRに読み込んで、lubridateパッケージを使って日付フィールドにいくつかの基本的なハウスキーピングを行っています。その後、Nicoleがhflightsデータセットについてhereと表示しているものに従っています。これは、関連するコードです:私はforループを実行したときにRNeo4jで `appendCypher()`を使用しているときのエラー

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) 

しかし、私は次のエラーを取得する:

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はこれを気にしませんか?

ここで助けていただければ幸いです。

+0

あなたはComplaintIDにリストを渡している、そしてそれは文字列または数値 –

+0

'STR(苦情$ Complaint.ID)'それは整数だことを明らかに期待しています。 – Dhiraj

答えて

0

ループはforの本当にばかげたミスです。これはどのような作品です:

for(i in 1:nrow(complaint)) { 
    row = complaint[i, ] 
    appendCypher(tx, query, 
       ComplaintID=row$Complaint.ID, 
       ComplaintDay=row$Complaint.Day, 
       ComplaintMonth=row$Complaint.Month, 
       ComplaintYear=row$Complaint.Year, 
       CompanyName=row$Company, 
       Companyresponsetoconsumer=row$Company.response.to.consumer, 
       Timelyresponse=row$Timely.response., 
       Consumerdisputed=row$Consumer.disputed.) 
} 
関連する問題