Description Usage Arguments Details Value See Also Examples
View source: R/mongo_high_level.R
Aggregation pipeline
1 2 |
mongo |
(mongo) A mongo connection object. |
ns |
(string) The namespace of the collection in which to find distinct keys. |
pipeline |
(list of mongo.bson objects) representing aggregation query pipeline.
Alternately, Alternately, |
explain |
(logical) Optional, MongoDB 2.6+. Specifies to return the information on the processing of the pipeline. References above. |
allowDiskUse |
(logical) Optional, MongoDB 2.6+. Enables writing to temporary files. When set to true, aggregation stages can write data to the _tmp subdirectory in the dbPath directory. |
cursor |
(mongo.bson) Optional, MongoDB 2.6+. Specify a document that contains options that control the creation of the cursor object. |
... |
Arguments to be passed to methods, such as mongo.bson.to.list, fromJSON Unfortunately, current underlying mongo-c-driver can return BSON from aggreagation camand. Cursors are not supported. Alternately, Alternately, |
See http://docs.mongodb.org/manual/reference/command/aggregate/ http://docs.mongodb.org/manual/core/aggregation-pipeline/.
NULL if the command failed. mongo.get.err()
may be
MONGO_COMMAND_FAILED.
mongo.bson The result of aggregation.
mongo.command
,
mongo.simple.command
,
mongo.find
,
mongo.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | # using the zips example data set
mongo <- mongo.create()
# insert some example data
data(zips)
colnames(zips)[5] <- "orig_id"
ziplist <- list()
ziplist <- apply( zips, 1, function(x) c( ziplist, x ) )
res <- lapply( ziplist, function(x) mongo.bson.from.list(x) )
if (mongo.is.connected(mongo)) {
mongo.insert.batch(mongo, "test.zips", res )
pipe_1 <- mongo.bson.from.JSON('{"$group":{"_id":"$state", "totalPop":{"$sum":"$pop"}}}')
cmd_list <- list(pipe_1)
res <- mongo.aggregation(mongo, "test.zips", cmd_list)
}
mongo.destroy(mongo)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.