# Connecting to a MongoDB database from R using the C API for MongoDB

[This article was first published on

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Today, Neil posted an article titled” Connecting to a MongoDB database from R using Java”. In the current post, I’ll show how to use the C API for MongoDB to fetch some MongoDB data from R. The code will be somehow similar to my previous post “A stateful C function for R: parsing Fasta sequences”.OK, First, let’s add a few values in mongo:for(i=1;i> 20;++i) db.dbsnps.save({_id:”rs”+i,name:
**YOKOFAKUN**, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

To

**leave a comment**for the author, please follow the link and comment on their blog:**YOKOFAKUN**.R-bloggers.com offers

**daily e-mail updates**about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.

Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.