Youtube video: Proper steps to integrate MongoDB NOSQL database with R on Ubuntu Linux with RStudio

Bryan D

Bryan D

Youtube video: Proper steps to integrate MongoDB NOSQL database with R on Ubuntu Linux with RStudio

Why NOSQL?

When comparing other RDMS including Oracle, MySQL or DB/2 against NOSQL, I was one of those old geezers who thought they were another ‘go fast nowhere’ technology trend.

Boy, was I wrong! I looked at all the options including HBase/Hadoop, Cassandra, Redis, and MongoDB. I found Hbase and Hadoop were difficult to install. The R packages for these were useless as there were few installation documents. Cassandra was easy but the the client support for R either didn’t exist or didn’t work with the RCassandra package. Redis looked awesome and is still one of the best for R thanks to the doRedis R package. The Java examples to shard looked promising too.

Then I revisited everything and came across MongoDB. It seems to have all the advantages of Cassandra and Redis with decent R package support.

NOSQL options and R

After looking at all the options, my recommended NOSQL databases is Redis or MongoDB. It was easy to install Redis but tricky with MongoDB. My recommendation is to install MongoDB with a clean current Ubuntu Linux Desktop version. All you need to do is type the following on the command line:

‘apt-get install mongo’

… and you’re ready to go. It takes care of all the permissions, users, etc. It was so easy that I could have saved a day’s work without going through the hoops I did. A lesson learned, and the time I lost is time you can save!

MongoDB install obstacles and tricks

Here are some current tricks to save you even more time:

Install Open JDK 6 not 7 as it will mess up the RJava install with R

If this happens, keep an eye out for a message that says something to the effect of checking your Linux Java environment. It will say you need to run as root, R CMD java or something similar. This message would be appear in your R console during the RJava package install. My problem came to Java 7 versus 6 which resolved it.

Create your MongoDB mydb data with:

http://www.mongodb.org/display/DOCS/Tutorial
http://pseudofish.com/blog/2011/05/25/analysis-of-data-with-mongodb-and-r/

Once installed, you should be able to do the following within your R shell or RStudio:
for RMongo:

> library(“RMongo”)

Loading required package: RUnit

> mongo <- mongoDbConnect(“mydb”)
> dbShowCollections(mongo)
[1] “system.indexes” “things”
> results <- dbGetQuery(mongo, “nutrient_metadatas”, “{}”, 0, 2)
> results <- dbGetQuery(mongo, “things”, “{}”, 0, 2)
> names(results)
[1] “X_id” “name”
> dbDisconnect(mongo)

[youtube_sc url=”http://www.youtube.com/watch?v=DbhdKBx-lK0″ playlist=”How to, Integrate, MongoDB ,NOSQL, database ,R , Ubuntu, Linux, RStudio ” title=”How%20to%20Integrate%20MongoDB%20NOSQL%20database%20with%20R%20on%20Ubuntu%20Linux%20with%20RStudio%20″]

Related Articles

Wishlist Member WooCommerce Plus - Sell Your Membership Products With WooCommerce The Right Way .

Powered by WishList Member - Membership Software