Description Overview Author(s)
The functions in this package allow you make queries with a MongoDB database from R.
A typical workflow using RMongo:
Connect to a mongodb database:
mongo <- mongoDbConnect("test", "localhost", 27017)
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"}')
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}')
Close the connection:
dbDisconnect(mongo)
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 <tommy.chheng@gmail.com> http://tommy.chheng.com
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.