Intro to R Markdown Ryan Brush INFX 561
Intro to R Markdown Ryan Brush INFX 561 August 2016
Outline § Preface § Markdown process § R Code Chunks § Markdown Basics § Tour of output formats § Installing R Markdown § Exercises
Research Pipeline Roger D. Peng, Reproducible Research: Concepts and Ideas p. 10 on Coursera
“… about half of published results across medicine were inflated or wrong… the problem could be even worse in other fields, including cell biology, economics, neuroscience, clinical medicine, and animal research. ” Carey, Benedict. "Many Psychology Findings Not as Strong as Claimed, Study Says. " The New York Times, 27 Aug. 2015. Web. 23 May 2016.
R Markdown A convenient tool to generate a reproducible document. § Markdown § Remove HTML tag for higher readability § Inline HTML is available § R markdown § Markdown + embedded R code chunks § Rmd -> html(docx, pdf) § Why R Markdown § Consolidate your code and document into single file § Easy for version control
R Markdown http: //rmarkdown. rstudio. com/
R Markdown Quick Tour http: //rmarkdown. rstudio. com/authoring_quick_tour. html
Overview § YAML Metadata: YAML document options § Markdown: Article text § R Code Chunk: Executible R code
R Markdown Basics § http: //rmarkdown. rstudio. com/authoring_basics. html
Tour of R Markdown Examples § http: //rpubs. com/ § http: //rmarkdown. rstudio. com/gallery. html § PDF Example (Ryan’s)
Installing R Markdown
Installing R Markdown
Exercise 1 Think you have it? Install the current versions of R Markdown. Then: 1. Open a new R Markdown file in the IDE (start with an HTML document template) 2. Render the document by clicking the knit button at the top of the file 3. Compare the output with the. Rmd file 4. Find the. html output file on your computer
Exercise 2 Did you pass Exercise 1? Ok, now modify the. Rmd file: 1. Add another R code chunk for a different plot with the same data set. Run it with another image rendered 2. Hide the R code, but render image 3. Add a floating table of contents
More resources § R Markdown § http: //rmarkdown. rstudio. com/index. html § http: //jeromyanglim. blogspot. com/2012/05/getting-started-with-r-markdown -knitr. html § http: //www. htmlwidgets. org/ § ggplot 2 § http: //tutorials. iq. harvard. edu/R/Rgraphics. html § http: //www. statmethods. net/advgraphs/ggplot 2. html § http: //docs. ggplot 2. org/0. 9. 2. 1/ggplot. html § Visualizations § https: //www. propublica. org/article/how-information-graphics-reveal-yourbrains-blindspots? utm_source=pardot&utm_medium=email&utm_campaign=dailynewsle tter
Questions
- Slides: 18