r programming with mongodb - prof. bhavana khivsara · 2017. 2. 28. · installation of mongo...
TRANSCRIPT
![Page 1: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/1.jpg)
R Programming
with MongoDB
Prepare by Prof. B.A.Khivsara
Assistant Professor, Department of Computer Engineering,
SNJB’s K.B. Jain COE,Chandwad
![Page 2: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/2.jpg)
Outline
Installation of R
Installation of RStudio
Installation of Mongo
Integration of Rmongo package into Rstudio
Program in RMongo
![Page 3: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/3.jpg)
Outline
Installation of R
Installation of RStudio
Installation of Mongo
Integration of Rmongo package into Rstudio
Program in RMongo
![Page 4: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/4.jpg)
R
R is a programming language and software environment for statistical analysis, graphics representation and reporting.
![Page 5: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/5.jpg)
Installation of R
https://cran.r-project.org/
Download R for Windows
install R for the first time.
Download R 3.3.2 for Windows (62 megabytes, 32/64 bit)
![Page 6: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/6.jpg)
Installation of R….
Click on Save File Option
![Page 7: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/7.jpg)
Installation of R….
![Page 8: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/8.jpg)
Installation of R….
![Page 9: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/9.jpg)
Installation of R….
![Page 10: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/10.jpg)
Installation of R….
![Page 11: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/11.jpg)
Installation of R….
![Page 12: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/12.jpg)
Installation of R….
![Page 13: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/13.jpg)
Installation of R….
![Page 14: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/14.jpg)
Installation of R….
![Page 15: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/15.jpg)
Installation of R….
![Page 16: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/16.jpg)
Installation of R….
![Page 17: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/17.jpg)
Installation of R….
You will see following Icon on your Desktop after successful completion of R Installation
![Page 18: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/18.jpg)
R….First look
![Page 19: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/19.jpg)
R….First Command
![Page 20: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/20.jpg)
Outline
Installation of R
Installation of RStudio
Installation of Mongo
Integration of Rmongo package into Rstudio
Program in RMongo
![Page 21: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/21.jpg)
Installation of R studio
RStudio makes R easier to use. It includes a code editor, debugging & visualization tools.
RStudio is a set of integrated tools designed to help you be more productive with R. It includes a console, syntax-highlighting editor that supports direct code execution, and a variety of robust tools for plotting, viewing history, debugging and managing your workspace.
![Page 22: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/22.jpg)
Installation of R studio….
Open a browser and type following Web address
http://www.rstudio.com
![Page 23: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/23.jpg)
Installation of R studio…
• Following page will be displayed click on suitable option that you
want to download(Here I downloaded Rstudio Desktop-Opensource)
![Page 24: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/24.jpg)
Installation of R studio…..
Select proper version of Rstudio according to your OS Version.
![Page 25: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/25.jpg)
Installation of R studio…..
Click on Save File Option
![Page 26: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/26.jpg)
Installation of R studio…..
![Page 27: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/27.jpg)
R studio has Installed
successfully
![Page 28: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/28.jpg)
Open R studio folder and click
on bin folder
![Page 29: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/29.jpg)
Find rstudio in bin folder and
click on it.
![Page 30: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/30.jpg)
![Page 31: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/31.jpg)
![Page 32: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/32.jpg)
• Ctr+L to clear console screen
![Page 33: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/33.jpg)
![Page 34: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/34.jpg)
Outline
Installation of R
Installation of RStudio
Installation of Mongo
Integration of Rmongo package into Rstudio
Program in RMongo
![Page 35: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/35.jpg)
Installation of Mongo
Create one folder eg SNJB in bin folder of MongoDB
Goto command prompt
Goto bin dir of MongoDB and write following command
mongod --storageEngine=mmapv1 --dbpath SNJB (Server will started and listen at 27017 port)
Open another command prompt and give command mongo (Client will be started)
![Page 36: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/36.jpg)
Outline
Installation of R
Installation of RStudio
Installation of Mongo
Integration of Rmongo package into Rstudio
Program in RMongo
![Page 37: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/37.jpg)
RMongo & rjava Packages in RStudio
• Open Rstudio and on console write
• >install.packages(“Rmongo”)
• If error comes for Internet Connection then
– Set no proxy setting
– Default browser set Internet Explorer
• In Rstudio Menu ->Tool ->Global Options ->
Packages -> Uncheck use Inrenet explorer
library/proxy for HTTP and try again to
install.packages(“Rmongo”)
![Page 38: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/38.jpg)
RMongo & rjava Packages in RStudio
• In rignt side bottom window in Rstudio
• Package tab
• Check rjava and Rmongo
• If error comes then need to install java version from official website which will be compatible with R version you are using.
• If no error comes then write following command on console
• >help(package=Rmongo)
![Page 39: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/39.jpg)
Outline
Installation of R
Installation of RStudio
Installation of Mongo
Integration of Rmongo package into Rstudio
Program in RMongo
![Page 40: R Programming with MongoDB - Prof. Bhavana Khivsara · 2017. 2. 28. · Installation of Mongo Create one folder eg SNJB in bin folder of MongoDB Goto command prompt Goto bin dir of](https://reader035.vdocuments.net/reader035/viewer/2022062606/5fe5a68fd0871340043c1215/html5/thumbnails/40.jpg)
First RMongo Script/Program
library(RMongo)
mg1<-mongoDbConnect('db1')
dbShowCollections(mg1)
dbInsertDocument(mg1,"stud",'{rno:1,name:"Amit"}')
res<-dbGetQuery(mg1,'stud',"{ }")
print(res)
• Note: Before running script make sure that Mongo
Server is started.