我有一份Twitter数据的CSV文件,我已经使用read.table
在R中读取了该文件,然后对该数据执行了一些算法,得到了表格数据。我想将这个表格数据插入到mongodb
中。有人可以帮忙吗?
表格数据大致如下:
pqr
V2 V1 V3 V4 polarity emotion
1 342521635332_318304224958367 FB 2013-03-15 6:43 PM positive <NA>
2 342521635332_325506614238815 FB 2013-03-08 8:23 PM neutral sad
3 342521635332_347654842010216 FB 2013-02-22 8:13 PM positive <NA>
4 342521635332_567940913224072 FB 2013-02-22 6:27 PM neutral <NA>
5 342521635332_318826431554118 FB 2013-02-22 2:22 PM positive joy
6 342521635332_215298638612191 FB 2013-02-20 8:09 PM negative angry
7 342521635332_407970722630311 FB 2013-02-15 8:48 PM neutral joy
mongo.insert(m,'abc.xyz',pqr)
当我执行
mongo insert
时,数据被插入到mongodb
中,但在mongodb中查看数据如下。db.xyz.find()
{ "_id" : ObjectId("5176273533da42cdbe49f2c5"), "V2" : [ 3, 5, 6, 9, 4, 2, 7, 1, 10, 8 ], "V1" : [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ], "V3" : [ 6, 5, 4, 4, 4, 3, 2, 1, 1, 1 ], "V4" : [ 5, 8, 7, 4, 1, 6, 10, 9, 3, 2 ], "polarity" : [ 3, 2, 3, 2, 3, 1, 2, 2, 3, 1 ], "emotion" : [ -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, -2147483648, 1, -2147483648, -2147483648, -2147483648 ] }
我需要将数据插入到mongodb中,类似于表格数据的形式。
data.frame
形式呈现?如果是的话,您能否提供一些来自str(mydata)
的输出? - dardisco