Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your...
Transcript of Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your...
![Page 1: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/1.jpg)
Buildinginteractiveandreproduciblereportsinminutes
IntroductiontoRMarkdown
Yan-holtz.com/teaching
![Page 2: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/2.jpg)
What
“AnRMarkdown(.Rmd)fileisarecordofyourresearch.Itcontainsthecode thatascientistneedstoreproduceyourworkalongwiththenarration thatareader
needstounderstandyourwork.“
Why
• Efficiency• Reproducibility• Interactivity• Automation• Notebook
Andmuchmore..
![Page 3: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/3.jpg)
MostBasicDocument
![Page 4: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/4.jpg)
1- OpenRstudio:
• UserFriendlyenvironment• Autocompletion• RunalineofcodewithCmd +Enter
![Page 5: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/5.jpg)
2- Opena.Rmd file:
![Page 6: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/6.jpg)
Anatomyofa.Rmd file:
Header
Title
Text
Codechunk
![Page 7: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/7.jpg)
3- Knitthe.Rmd file:
![Page 8: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/8.jpg)
.html.rmd4- .HTML
outputisready
• Havealooktoyourcurrentdirectory
• Openthe.htmlinabrowser
header
TitleText
Code
Coderesult
![Page 9: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/9.jpg)
Customize text
![Page 10: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/10.jpg)
Customizethetext
RMarkdowncheatsheet
bit.ly/1SuNTo9
![Page 11: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/11.jpg)
Codechunk options
![Page 12: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/12.jpg)
AnatomyofaCodechunk:
Optional:chunk nameR,bash,
python?
Chunkoptions
Run allpreviouschunks
Run thischunk
Commentyour code
![Page 13: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/13.jpg)
Codechunkoptions:
![Page 14: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/14.jpg)
Donotalwaysrunthewholedocument
à RMarkdowndocumentis aNotebook!!
![Page 15: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/15.jpg)
Header
![Page 16: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/16.jpg)
Anatomyoftheheader:
![Page 17: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/17.jpg)
Going further
![Page 18: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/18.jpg)
Insertatable:theDTlibrary
Dataframe
![Page 19: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/19.jpg)
UseInteractivecharts
Plotly library
Basicggplot2graphic
Ggplotly turn theplotinteractive
Result:zoom/hover /export..Andmore
http://www.htmlwidgets.org
![Page 20: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/20.jpg)
Useatemplate• ThePCTGtemplate:www.github.com/holtzy/epuRate
![Page 21: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/21.jpg)
Pimpmy.Rmd
• holtzy.github.io/Pimp-my-rmd/
• Everything is possible
• UseCSSandHTMLcode
• Add headerandfooter
• More
![Page 22: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/22.jpg)
Sharing
![Page 23: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/23.jpg)
Outputformat?
Word.doc.pdf
Book
TemplateDashboard
Slides
Blog
![Page 24: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/24.jpg)
Shareyouranalysis
• Mailwithcolleagues,supervisor
• Publicationasasupplementarymaterial
• Github:www.github.com
• Website
![Page 25: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/25.jpg)
Example
![Page 26: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/26.jpg)
Anexample:mybioinfo pipeline:
• Interactionwith clusters
• Oneuniquefolder
• Several .rmd wrapped inawebsite
• Shared online
![Page 27: Introduction to R Markdown - Yan Holtz · “ An R Markdown (.Rmd) file is a record of your research. It contains the code that a scientist needs to reproduce your work along with](https://reader030.fdocuments.us/reader030/viewer/2022040900/5e705f62fbc39467ca1728ee/html5/thumbnails/27.jpg)
Thanks
bit.ly/2SxJFlVSlides:
bit.ly/2AZySd9Cheat Sheet:
bit.ly/2QDX7HzPimp my rmd:
www.yan-holtz.com
@R_Graph_Gallery
github.com/holtzy