[英]Extract data from mongoDB with rmongodb
I have the following code in R: 我在R中有以下代码:
library("rmongodb")
mongo <- mongo.create(<host>)
mongo.is.connected(mongo)
collection<-mongo.get.database.collections(mongo, 'words')
store <-mongo.find.all(mongo,collection)
When I print the store I get: 当我打印商店时,我得到:
[[1]] [[1]]$`_id` [1] "56c462be97819a3e6320e595"
[[1]]$word [1] "short"
[[2]] [[2]]$`_id` [1] "56c462c597819a3e6320e596"
[[2]]$word [1] "long"
The problem here is that I don't how to get the the whole word field and how to get a single entry, like 'short' and 'long'. 这里的问题是我没有如何获取整个单词字段以及如何获得单个条目,例如“ short”和“ long”。
I've searched for some time and still don't get it. 我搜索了一段时间,但仍然听不懂。
mongo.get.values(mongo, "words", "word")
cursor <- mongo.find(mongo, "words", query='{"word":"short"}')
list <- mongo.cursor.to.list(cursor)
helpful cheatsheet: 有用的备忘单:
https://cran.r-project.org/web/packages/rmongodb/vignettes/rmongodb_cheat_sheet.pdf https://cran.r-project.org/web/packages/rmongodb/vignettes/rmongodb_cheat_sheet.pdf
hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.