Description Usage Arguments See Also Examples
Send a set of aggregate pipeline commands to mongodb. The output is a data.frame object and will work properly only if the mongoDB collection contains primitive data types. It may not work properly if there are any embedded documents or arrays.
1 | dbAggregate(rmongo.object, collection, query)
|
rmongo.object |
The RMongo object. |
collection |
The name of the collection the query is being performed upon. |
query |
A vector of pipeline command in JSON format. See http://docs.mongodb.org/manual/reference/aggregation/ for more information on the MongoDB aggregation framework. |
1 2 3 4 5 6 7 8 | mongo <- mongoDbConnect("test")
# insert two records
dbInsertDocument(mongo, "test_data", '{"foo": "bar", "size": 5 }')
dbInsertDocument(mongo, "test_data", '{"foo": "nl", "size": 10 }')
output <- dbAggregate(mongo, "test_data", c(' { "$project" : { "baz" : "$foo" } } ',
' { "$group" : { "_id" : "$baz" } } ',
' { "$match" : { "_id" : "bar" } } '))
print(output)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.