Reporting Reproducible Research with R and Markdown Garrick Aden-Buie // April 11, 2014 INFORMS Code & Data Boot Camp Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 1 / 46
Lots of things to install Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 2 / 46 http://www.tug.org/mactex/morepackages.html � LaTeX � Mac: BasicTeX � Windows: MiKTeX http://miktex.org/ � Linux: apt-get install texlive � pandoc � http://johnmacfarlane.net/pandoc � R � http://r-project.org � http://rstudio.com � knitr � http://yihui.name/knitr/ � Go all out: git � http://git-scm.org
Garrick Aden-Buie // April 11, 2014 Skip the talk, learn at home Reporting Reproducible Research with R and Markdown 3 / 46 � pandoc user guide � http://johnmacfarlane.net/pandoc/README.html � knitr user guide � http://yihui.name/knitr/ � http://kbroman.github.io/knitr_knutshell/ � git � https://bitbucket.org/gadenbuie/intro-to-git-for-scientists
Garrick Aden-Buie // April 11, 2014 Today we’ll talk about Reporting Reproducible Research with R and Markdown 4 / 46 � What’s the deal with Reproducible Research? � What’s up with Markdown? � A complete research flow � A simple example � Show and tell
Reproducible research What’s the deal with Reproducible Research? …is the idea that data analyses, and more generally, scientific claims, are published with their data and software code so that others may verify the findings and build upon them. Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 5 / 46 � Kind of a hot topic these days � Coursera’s course � PLoS One Data Policy � RunMyCode � Code & Data are as much a part of research output as pubs
Write once, output to anything Make collaboration easier 1 and more scalable Why should you care? Start to finish, integrate everything 1 YMMV Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 6 / 46 � Version Control and Management!
Make collaboration easier 1 and more scalable Why should you care? Write once, output to anything 1 YMMV Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 7 / 46 � Version Control and Management! � Start to finish, integrate everything
Make collaboration easier 1 and more scalable Why should you care? 1 YMMV Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 8 / 46 � Version Control and Management! � Start to finish, integrate everything � Write once, output to anything
Why should you care? 1 YMMV Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 9 / 46 � Version Control and Management! � Start to finish, integrate everything � Write once, output to anything � Make collaboration easier 1 and more scalable
Which reminds me… Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 10 / 46
A complete research flow Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 11 / 46
The core workflow Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 12 / 46
The full workflow Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 13 / 46
Mendeley Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 14 / 46
Set up Mendeley + BibTeX Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 15 / 46
Where to find the citekey Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 16 / 46
BibTeX entry of Stations of a Mixed Fleet Biking System: An Application Reporting Reproducible Research with R and Markdown Garrick Aden-Buie // April 11, 2014 } year = {2012} volume = {54}, url = {http://www.sciencedirect.com/science/article/pii/S1877042812042310}, to the City of Lisbon}}, title = {{An Optimisation Algorithm to Establish the Location ~/Dropbox/USF/Resources/BibTeX/library.bib pages = {513--524}, month = oct, journal = {Procedia - Social and Behavioral Sciences}, issn = {18770428}, doi = {10.1016/j.sbspro.2012.09.769}, author = {Martinez, Luis M. and Caetano, Luis}, @article{Martinez2012, 17 / 46
What’s up with Markdown? Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 18 / 46
What is markdown? Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 19 / 46 � The ctrl+B of plain text � Many variants, modern markdown father: � https://daringfireball.net/projects/markdown/ � Lots of variants, but same idea: plain-text readable markup � MultiMarkdown � Github-flavored markdown � ReST � TeX � pandoc has it’s own special features � General concept: think like HTML or Word “styles”
Markdown crash course Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 20 / 46
Let’s walk through an example together http://bit.ly/1qIyQbv 2 2 http://www.unexpected-vortices.com/sw/gouda/quick-markdown- example.html Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 21 / 46
Title Pandoc allows special syntax on the first three lines for document metadata. % Title % Author % 2014-04-11 Or YAML metadata blocks. Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 22 / 46
Headers Two ways to make headers, think <h1> , <h2> , … levels. An h1 header ============ An h2 header ------------ # Also h1 header ## Also h2 header Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 23 / 46
Paragraphs Paragraphs are separated by a blank line. I like starting new sentences on a new line. It’s odd, I know. Paragraphs are separated by a blank line. I like starting new sentences on a new line. It’s odd, I know. Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 24 / 46
Formatting Formatting is easy: *italics*, **bold**, ‘monospace‘, ~~strikethrough~~. Also H~2~O and Na^+^. Formatting is easy: italics , bold , monospace , strikethrough. Also H 2 O and Na + . Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 25 / 46
Lists - Item 1 1. Sub item 1 Still sub item 1 - Item 2 1. Sub item 1 Still sub item 1 Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 26 / 46 � Item 1 � Item 2
Block quotes > Block quotes are > written like so. > > They can span multiple paragraphs, > if you like. Block quotes are written like so. They can span multiple paragraphs, if you like. Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 27 / 46
Code Sample Code samples start with three ‘ characters or three ~ or are indented 4 spaces, and can include the code style. ‘‘‘r hist(rnorm(100)) ‘‘‘ Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 28 / 46
Tables size Reporting Reproducible Research with R and Markdown Garrick Aden-Buie // April 11, 2014 transparent glass 11 natural hemp canvas 10 brown leather 9 color material transparent Tables can look like this: glass 11 natural hemp canvas 10 brown leather 9 ------------ ------------ ---- color material size 29 / 46
Tables 2 10 Table: This table has a caption. size material color 9 leather brown hemp canvas | natural 11 glass transparent Table 2: This table has a caption. Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown transparent | glass Or they can also look like this: leather |size | material | color | |:----|:------------:|--------------:| | 9 | | | brown | | 10 | hemp canvas | natural | | 11 30 / 46
Links There are a [couple] of ways to [make][foo] a [link](http://bing.com). <http://garrickadenbuie.com> [couple]: http://google.com [foo]: http://xkcd.com There are a couple of ways to make a link. http://garrickadenbuie.com Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 31 / 46
Footnotes Footnotes are very similar to links[^disclaimer]. [^disclaimer]: Don’t believe everything this guy says. Footnotes are very similar to links 3 . 3 Don’t believe everything this guy says. Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 32 / 46
LaTeX Math Inline math equations go in like so: $\omega = d\phi / dt$. Display math should get its own line and be put in in double-dollar signs: $$I = \int \rho R^{2} dV$$ should get its own line and be put in in double-dollarsigns: Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 33 / 46 Inline math equations go in like so: ω = d φ / dt . Display math ∫ ρ R 2 dV I =
pandoc Garrick Aden-Buie // April 11, 2014 Reporting Reproducible Research with R and Markdown 34 / 46
Recommend
More recommend