RMongo: Accessing MongoDB in R
I recently created RMongo, a database access layer to MongoDB in R as an R package.
To install RMongo:
install.packages(“RMongo”)
If that does not work, try downloading it from http://cran.r-project.org/web/packages/RMongo/index.html and run:
install.packages("~/Downloads/RMongo_XX.XX.XX.tar.gz", repos=NULL, type="source")
I tried to mimic the RMySQL commands in RMongo. Below are some example commands.
library(RMongo)
#ask for help
?RMongo
#connect to a database
mongo results names(results)
[1] “X_id” “name” “nutrient_definition_id” “description”
> results
X_id name nutrient_definition_id
1 4cd0f8e31e627d4e6600000e Adjusted Protein 257
2 4cd0f9061e627d4e6600001a Sodium 307
> results results
X_id name nutrient_definition_id
1 4cd0f9061e627d4e6600001a Sodium 307
> dbDisconnect(mongo)
RMongo is very alpha at this point. I built it as a quick way to prototype algorithms with data from mongoDB in R. Most of RMongo uses the mongo-java-driver to perform json-formatted queries. The R code in the package uses rJava to communicate with the mongo-java-driver.
Please report any bugs or necessary improvements. Or better yet, send in pull requests via the RMongo github project page!