Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Which package to use to connect R with MongoDB? [closed]

I wonder what are the main differences between rmongodb and RMongo packages for connecting R with MongoDB. What are the advantages and disadvantages of these two packages?

like image 622
AnjaM Avatar asked Jan 29 '14 09:01

AnjaM


People also ask

Which module is used to connect with MongoDB?

The MongoDB module exports MongoClient , and that's what we'll use to connect to a MongoDB database. We can use an instance of MongoClient to connect to a cluster, access the database in that cluster, and close the connection to that cluster.

Should MongoDB connection be closed?

There is no need for closing the connection explicitly. This way the application avoids creating and closing connections (which is an expensive operation).

Which data format is supported by MongoDB?

MongoDB Server stores data using the BSON format which supports some additional data types that are not available using the JSON format.


1 Answers

library(rmongodb)

your connection details will likely differ from these defaults

host <- "someone.com:10200"
username <- "myuser"
password <- "mypassword"
db <- "testdatabase"

connect to mongo and then create function has the following signature

mongo <- mongo.create(host=host , db=db, username=username, password=password)

Also

> library("RMongo")
> mongo  < - mongoDbConnect("db")

RMango: MongoDB Database interface for R. The interface is provided via Java calls to the mongo-java-driver.
rmongodb: This R package provides an interface to the NoSQL MongoDB database using the MongoDB C-driver.

While RMongo package is very straight-forward and user-friendly, it did take me a while to figure out how to specify a query with rmongodb package

Supported Functionality by rmongodb

  • Connecting and disconnecting to MongoDB Querying, inserting and
  • updating to MongoDB including with JSON and BSON Creating and
  • handling BSON objects Dropping collections and databases on MongoDB
  • Creating indices on MongoDB collections Error handling Executing
  • commands on MongoDB Adding, removing, handling files on a "Grid File
  • System" (GridFS) on a MongoDB server High Level functionality as
  • mongo.apply, mongo.summary, mongo.get.keys, ...
like image 144
Prasanna Nandakumar Avatar answered Nov 15 '22 01:11

Prasanna Nandakumar