I use rmongodb to read and display some information from local host mongo db. Data is inserted directly using mongo shell. There is a text file MongoDataManipulation.txt that shows the data manipulation commands and the test data

Install necessary packages and load them

#install.packages("rmongodb")
library(rmongodb)

Connect to local host and check the connection status

m<-mongo.create()
mongo.is.connected(m)
## [1] TRUE

list the collection of databases

mongo.get.databases(m)
## [1] "test"     "database" "db"

Get a list of collection from the test db, where the data is stored.

mongo.get.database.collections(m, db = "test")
## [1] "test.inventory"

Get the count of documents in my collection

ns <- "test.inventory"
mongo.count(m, ns = ns)
## [1] 2

Get all the documents from the collections.

Display the count of documents fetched

Display some information from the second document fetched

find_all <- mongo.find.all(m, ns = ns)
sprintf("Records count in the collection is %i", NROW(find_all))
## [1] "Records count in the collection is 2"
sprintf("For Item %s:- Manufacturer is %s and Category is %s", find_all[[2]]$item, find_all[[2]]$details$manufacturer, find_all[[2]]$category)
## [1] "For Item MNO2:- Manufacturer is ABC Company and Category is clothing"