Introducing R Shiny and R notebook: R collaborative tools

27
Improve your Performance with R Notebook R Shiny Xavier Prudent Data Scien<st – Consultant in data mining and machine learning www.xavierprudent.com Max Planck Ins<tute Cell Biology and Gene<cs 23 th January 2017

Transcript of Introducing R Shiny and R notebook: R collaborative tools

Page 1: Introducing R Shiny and R notebook: R collaborative tools

ImproveyourPerformancewithRNotebookRShiny

XavierPrudentDataScien<st–Consultantindataminingandmachinelearning

www.xavierprudent.com

MaxPlanckIns<tuteCellBiologyandGene<cs

23thJanuary2017

Page 2: Introducing R Shiny and R notebook: R collaborative tools

RStudioh#ps://www.rstudio.com/products/rstudio/download/RshinyInstall.packages(“shiny”)

AllyouneedisR

Page 3: Introducing R Shiny and R notebook: R collaborative tools

WALL OF SHAME – PART 1

Page 4: Introducing R Shiny and R notebook: R collaborative tools

Analyzing&tes<ngallalongtheyear(s)

•  manyback&forth•  documentasmuchasyoucan

ü flexibilitywhathappensifyousettheparameterto‘2’

ü paranoid

doyouhavethisplotyoushowedme3monthsago?ü reproducibility

Iwantthisplotbutchangetheblueforgreen

ReproducibilityinScienceiskey

Page 5: Introducing R Shiny and R notebook: R collaborative tools

knitr

RNotebookinapraline

Page 6: Introducing R Shiny and R notebook: R collaborative tools

R Notebook

RNotebook:appearancemaTers

Page 7: Introducing R Shiny and R notebook: R collaborative tools

Rcode

Variables,history

StandardRconsole

PlotsPackages

RStudio:auser-friendlyReditor

Page 8: Introducing R Shiny and R notebook: R collaborative tools

#1Crea<nganRnotebookdocument

Page 9: Introducing R Shiny and R notebook: R collaborative tools

Tocreatethereport

Detailsofthedocument(yourproject)

SyntaxtoincludeRcode

Comment

Pageorganiza<on(<tles)

BasiccodeforabasicreportinRNotebook

Page 10: Introducing R Shiny and R notebook: R collaborative tools

Comment

Detailsofthedocument(yourproject)

Rcode

Rprintout

Aswellasplots,warnings,errors…

BasicRNotebookisalreadywhatyouneed

Page 11: Introducing R Shiny and R notebook: R collaborative tools

#2PimpingupRnotebookdocument

Commen<ngout

Paragraphs

Maths

Lists

Tables

Page 12: Introducing R Shiny and R notebook: R collaborative tools

#3RunningR

AllstandardRcodes/analysiscanbeincluded!Automa<cresultintext

FullRanalysis(canbesourcedfromanexternalcode)

Page 13: Introducing R Shiny and R notebook: R collaborative tools

#4Preparingareport

Codewon’tberun

Coderunbutnotdisplayed

Coderun,errors&warningsnotdisplayed

Figuresize

Andmore:-makeyourdocumentinterac<vewithRshiny…-publishitonRstudio(well…)

Bigdatafile?Convertittoan.Rdatoopenitfaster

Page 14: Introducing R Shiny and R notebook: R collaborative tools

WALL OF SHAME – PART 2

Page 15: Introducing R Shiny and R notebook: R collaborative tools

forwardGenomics.R --analysis = 'local’ --list = elements.txt --tree = tree.mod --outFile = outFile --outPath = /user/dir/out/ --verb = TRUE --lossNodes = lossNode.txt --indepLoss = 1 --globalPid = globalPercent.txt --transf = 'raw' or 'ranked’ --localPid = localPercent.txt --weights = weights.txt --meanPid = meanPercentID.txt --neutProb = neutralProb.txt --collapseClades = ‘

Newcomers?Students?Inves<ga<on?

AUserFriendlySoeware

Page 16: Introducing R Shiny and R notebook: R collaborative tools

Javascript, css

R Shiny

RShinyinapraline

Page 17: Introducing R Shiny and R notebook: R collaborative tools

WebHTML

RShiny:crunchyandnicelooking

Page 18: Introducing R Shiny and R notebook: R collaborative tools

UserInterface

Serverinput

output

RShinyworkslikeastandardwebpage

Page 19: Introducing R Shiny and R notebook: R collaborative tools

#1Crea<ngaRShinydocument

Page 20: Introducing R Shiny and R notebook: R collaborative tools

Impor<ngthepackage

Pagelayout(rows,columns)

Userinput(slider)

Displayplot

Createplot

Runtheapp

Page 21: Introducing R Shiny and R notebook: R collaborative tools

#2RunningtheRShinyApp

Runtheapp

Sharetheapp>runApp("app.R")

AnyRinput/output/analysisispossible

Page 22: Introducing R Shiny and R notebook: R collaborative tools

#3PimpinguptheRShinyApp

Let’saddsomeCOLOR

Userinterface

Server

Page 23: Introducing R Shiny and R notebook: R collaborative tools

Manydifferenttypesofinputpossible

Page 24: Introducing R Shiny and R notebook: R collaborative tools
Page 25: Introducing R Shiny and R notebook: R collaborative tools

Reac<vityShouldthegiveninputbetakenimmediatelyintoaccount?

observeEvent()ReacAve()àvalues,useracAon,delay…

Goodlooking•  HTMLstaFctags:header,bold,italic•  CSSfilecanbeincluded•  Javascriptcodecanbeincluded•  Imagecanbeincluded(wwwdirectory)

Deploying

•  Intern:setupaRShinyserver•  Freeath#p://shinyapps.io

#4GoingfurtherwithRShiny

Page 26: Introducing R Shiny and R notebook: R collaborative tools

RnotebookRshiny

addcollabora<veassettothepowerofR

spreadingVERYfastthroughresearch,finance,insurance…

OpensourceAnalysis-friendlyUser-friendlyCareer-friendly

Page 27: Introducing R Shiny and R notebook: R collaborative tools

RNotebookhTp://rmarkdown.rstudio.com/r_notebooks.htmlh#ps://www.rstudio.com/wp-content/uploads/2015/02/rmarkdown-cheatsheet.pdfh#ps://yihui.name/knitr/

RShinyh#p://shiny.rstudio.com/tutorial/h#p://shiny.rstudio.com/images/shiny-cheatsheet.pdfh#ps://shiny.rstudio.com/gallery/

Ques<[email protected]

Dowanttoknowmore?