RMongo-package: MongoDB client for R.

Description Overview Author(s)


The functions in this package allow you make queries with a MongoDB database from R.


A typical workflow using RMongo:

  1. Connect to a mongodb database:

            mongo <- mongoDbConnect("test", "localhost", 27017)  
  2. Insert a document into a collection: This will insert a document of '"foo":"bar"' into the "test_data" collection.

            output <- dbInsertDocument(mongo, "test_data", '{"foo": "bar"}')
  3. Query a MongoDB collection: This will query for documents which have a "foo" attribute with the value of "bar". The return value will be a list of rjson objects or a converted data.frame depending on the format parameter. NOTE: nested documents and arrays may not work properly if you specify a data.frame.

            output <- dbGetQuery(mongo, "test_data", 
                                        '{"foo": "bar"}')

    or if you want only a particular set of keys:

            output <- dbGetQueryForKeys(mongo, "test_data", 
                                        '{"foo": "bar"}', '{"foo": 1}')
  4. Close the connection:

  5. Large result sets: Set your java heap space to a large number to support loading more results into memory.

            options( java.parameters = "-Xmx2g" )


Tommy Chheng <[email protected]> http://tommy.chheng.com

RMongo documentation built on May 30, 2017, 2:31 a.m.