RMongo: Accessing MongoDB in R
November 3, 2010 9 Comments
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 https://github.com/tc/RMongo/downloads and run:
install.packages("~/Downloads/RMongo_0.0.21.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!
Very cool, I added the driver to the MongoDB Drivers page:http://www.mongodb.org/display/DOCS/DriversEmail me (meghan@10gen.com) – would love to send you some swag as a thank you for your contribution!
There seems to be some bug or odd behaviour when trying to use mongodb with RMongo version 0.0.18.Connection goes normally:mongo.con<-mongoDbConnect(“tickets”,host=”localhost”,port=27017)But any attempt to use the connection results in Java IO exception:dbShowCollections(mongo.con)Feb 4, 2011 6:17:10 PM com.mongodb.DBTCPConnector$MyPort errorSEVERE: MyPort.error calledjava.io.IOException: couldn't connect to [machine.name/127.0.1.1:27017] bc:java.net.ConnectException: Connection refused at com.mongodb.DBPort._open(DBPort.java:172) at com.mongodb.DBPort.go(DBPort.java:79) at com.mongodb.DBPort.call(DBPort.java:55) at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:201) at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:256) at com.mongodb.DB.getCollectionNames(DB.java:200) at com.quid.RMongo.dbShowCollections(RMongo.scala:24)Any help is appreciated.
see https://github.com/quid/RMongo… for resolution
0.18 installs but with the latest ver. 0.20 I get the errors below…. what am I doing wrong?
———————————————–
c:>R CMD INSTALL RMongo_0.0.20.tar.gz
R CMD INSTALL RMongo_0.0.20.tar.gz
* installing to library ‘C:/Program Files/R/R-2.13.0/library’
* installing *source* package ‘RMongo’ …
** libs
C:/PROGRA~1/R/R-213~1.0/etc/i386/Makeconf:180: warning: overriding commands for target `.m.o’
C:/PROGRA~1/R/R-213~1.0/etc/i386/Makeconf:173: warning: ignoring old commands for target `.m.o’
ERROR: compilation failed for package ‘RMongo’
* removing ‘C:/Program Files/R/R-2.13.0/library/RMongo’
c:\>R CMD INSTALL RMongo_0.0.18.tar.gz
R CMD INSTALL RMongo_0.0.18.tar.gz
* installing to library ‘C:/Program Files/R/R-2.13.0/library’
* installing *source* package ‘RMongo’ …
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices …
** testing if installed package can be loaded
* DONE (RMongo)
——————————————————————————————
Pingback: #Rstats for Business Intelligence « DECISION STATS
Hi,
I want to try your RMongo (Just learning
but when I try:
R CMD install RMongo*.tar.gz
I get this error:
install: missing destination file operand after `RMongo_0.0.21.tar.gz’
Try `install –help’ for more information.
I’m not sure what destination file should I point RMongo to
Hope you can help me with this.
Thanks in advance
Which operating system are you using?
Can you try: install.packages(“RMongo”)
hi Tom, this great!, familiar with this…:) thank for sharing, perte de poids
That’s fantastic! thank you very much!