Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…
Cannot retrieve contributors at this time
53 lines (50 sloc) 1.67 KB
MongoDB client for R.
The functions in this package allow you make queries with a MongoDB database from R.
A typical workflow using RMongo:
\item Connect to a mongodb database:
mongo <- mongoDbConnect("test", "localhost", 27017)
\item 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"}')
\item 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}')
\item Close the connection:
\item 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 <>
Jump to Line
Something went wrong with that request. Please try again.