Preface |
|
xiii | |
Stylistic Conventions |
|
xvii | |
Required R Packages |
|
xix | |
Additional Resources |
|
xxi | |
List of Figures |
|
xxv | |
List of Tables |
|
xxvii | |
I Getting Started |
|
1 | (80) |
|
1 Introducing Reproducible Research |
|
|
3 | (16) |
|
1.1 What Is Reproducible Research? |
|
|
3 | (2) |
|
1.2 Why Should Research Be Reproducible? |
|
|
5 | (3) |
|
|
5 | (1) |
|
|
6 | (2) |
|
1.3 Who Should Read This Book? |
|
|
8 | (2) |
|
1.3.1 Academic researchers |
|
|
8 | (1) |
|
|
8 | (1) |
|
|
8 | (1) |
|
|
9 | (1) |
|
1.3.5 Private sector researchers |
|
|
9 | (1) |
|
1.4 The Tools of Reproducible Research |
|
|
10 | (1) |
|
1.5 Why Use R, knitr/rmarkdown, and RStudio for Reproducible Research? |
|
|
11 | (3) |
|
1.5.1 Installing the main software |
|
|
13 | (1) |
|
|
14 | (5) |
|
1.6.1 How to read this book |
|
|
16 | (1) |
|
1.6.2 Reproduce this book |
|
|
16 | (1) |
|
|
17 | (2) |
|
2 Getting Started with Reproducible Research |
|
|
19 | (10) |
|
2.1 The Big Picture: A Workflow for Reproducible Research |
|
|
19 | (3) |
|
2.1.1 Reproducible theory |
|
|
20 | (2) |
|
2.2 Practical Tips for Reproducible Research |
|
|
22 | (7) |
|
2.2.1 Document everything! |
|
|
22 | (2) |
|
2.2.2 Everything is a (text) file |
|
|
24 | (1) |
|
2.2.3 All files should be human readable |
|
|
24 | (2) |
|
2.2.4 Explicitly tie your files together |
|
|
26 | (1) |
|
2.2.5 Have a plan to organize, store, and make your files available |
|
|
27 | (2) |
|
3 Getting Started with R, RStudio, and knitr/rmarkdown |
|
|
29 | (36) |
|
|
29 | (16) |
|
|
30 | (6) |
|
3.1.2 Component selection |
|
|
36 | (2) |
|
|
38 | (1) |
|
3.1.4 Functions and commands |
|
|
39 | (1) |
|
|
40 | (2) |
|
3.1.6 The workspace & history |
|
|
42 | (2) |
|
|
44 | (1) |
|
3.1.8 Installing new packages and loading functions |
|
|
44 | (1) |
|
|
45 | (2) |
|
3.3 Using knitr and rmarkdown: The Basics |
|
|
47 | (18) |
|
|
48 | (1) |
|
3.3.2 What rmarkdown does |
|
|
48 | (2) |
|
|
50 | (1) |
|
|
50 | (3) |
|
3.3.5 Global chunk options |
|
|
53 | (2) |
|
3.3.6 knitr package options |
|
|
55 | (1) |
|
|
55 | (1) |
|
3.3.8 knitr, rmarkdown, & RStudio |
|
|
56 | (3) |
|
|
59 | (2) |
|
|
61 | (4) |
|
4 Getting Started with File Management |
|
|
65 | (16) |
|
4.1 File Paths & Naming Conventions |
|
|
66 | (3) |
|
|
66 | (1) |
|
4.1.2 Subdirectories & parent directories |
|
|
66 | (1) |
|
4.1.3 Working directories |
|
|
67 | (1) |
|
4.1.4 Absolute vs. relative paths |
|
|
67 | (1) |
|
4.1.5 Spaces in directory & file names |
|
|
68 | (1) |
|
4.2 Organizing Your Research Project |
|
|
69 | (1) |
|
4.3 Setting Directories as RStudio Projects |
|
|
70 | (1) |
|
4.4 R File Manipulation Commands |
|
|
70 | (4) |
|
4.5 Unix-like Shell Commands for File Management |
|
|
74 | (4) |
|
4.6 File Navigation in RStudio |
|
|
78 | (3) |
II Data Gathering and Storage |
|
81 | (70) |
|
5 Storing, Collaborating, Accessing Files, and Versioning |
|
|
83 | (26) |
|
5.1 Saving Data in Reproducible Formats |
|
|
84 | (1) |
|
5.2 Storing Your Files in the Cloud: Dropbox |
|
|
85 | (4) |
|
|
86 | (1) |
|
|
86 | (2) |
|
|
88 | (1) |
|
|
88 | (1) |
|
5.3 Storing Your Files in the Cloud: GitHub |
|
|
89 | (16) |
|
5.3.1 Setting up GitHub: Basic |
|
|
91 | (1) |
|
5.3.2 Version control with Git |
|
|
92 | (8) |
|
5.3.3 Remote storage on GitHub |
|
|
100 | (2) |
|
5.3.4 Accessing on GitHub |
|
|
102 | (3) |
|
5.3.4.1 Collaboration with GitHub |
|
|
104 | (1) |
|
5.3.5 Summing up the GitHub workflow |
|
|
105 | (1) |
|
|
105 | (4) |
|
5.4.1 Setting up Git/GitHub with Projects |
|
|
105 | (2) |
|
5.4.2 Using Git in RStudio Projects |
|
|
107 | (2) |
|
|
109 | (20) |
|
6.1 Organize Your Data Gathering: Makefiles |
|
|
109 | (8) |
|
|
110 | (1) |
|
|
111 | (7) |
|
|
112 | (4) |
|
6.1.2.2 Makefiles and RStudio Projects |
|
|
116 | (1) |
|
6.1.2.3 Other information about makefiles |
|
|
116 | (1) |
|
6.2 Importing Locally Stored Data Sets |
|
|
117 | (1) |
|
6.3 Importing Data Sets from the Internet |
|
|
118 | (7) |
|
6.3.1 Data from non-secure (http) URLs |
|
|
118 | (1) |
|
6.3.2 Data from secure (https) URLs |
|
|
119 | (2) |
|
6.3.3 Compressed data stored online |
|
|
121 | (2) |
|
|
123 | (2) |
|
6.4 Advanced Automatic Data Gathering: Web Scraping |
|
|
125 | (4) |
|
7 Preparing Data for Analysis |
|
|
129 | (22) |
|
7.1 Cleaning Data for Merging |
|
|
129 | (14) |
|
7.1.1 Get a handle on your data |
|
|
129 | (2) |
|
|
131 | (3) |
|
|
134 | (1) |
|
|
134 | (1) |
|
|
135 | (2) |
|
7.1.6 Recoding string/numeric variables |
|
|
137 | (2) |
|
7.1.7 Creating new variables from old |
|
|
139 | (3) |
|
7.1.8 Changing variable types |
|
|
142 | (1) |
|
|
143 | (10) |
|
|
143 | (1) |
|
|
143 | (3) |
|
|
146 | (1) |
|
|
147 | (4) |
III Analysis and Results |
|
151 | (62) |
|
8 Statistical Modeling and knitr |
|
|
153 | (14) |
|
8.1 Incorporating Analyses into the Markup |
|
|
154 | (5) |
|
|
154 | (2) |
|
8.1.2 Showing code & results inline |
|
|
156 | (3) |
|
|
156 | (2) |
|
|
158 | (1) |
|
8.1.3 Dynamically including non-R code in code chunks |
|
|
159 | (1) |
|
8.2 Dynamically Including Modular Analysis Files |
|
|
159 | (4) |
|
8.2.1 Source from a local file |
|
|
160 | (2) |
|
8.2.2 Source from a non-secure URL (http) |
|
|
162 | (1) |
|
8.2.3 Source from a secure URL (https) |
|
|
162 | (1) |
|
8.3 Reproducibly Random: set . seed |
|
|
163 | (1) |
|
8.4 Computationally Intensive Analyses |
|
|
164 | (3) |
|
9 Showing Results with Tables |
|
|
167 | (24) |
|
9.1 Basic knitr Syntax for Tables |
|
|
168 | (1) |
|
|
168 | (9) |
|
|
169 | (4) |
|
9.2.2 Tables in Markdown/HTML |
|
|
173 | (4) |
|
9.3 Creating Tables from Supported Class R Objects |
|
|
177 | (14) |
|
9.3.1 kable for Markdown and LaTeX |
|
|
177 | (1) |
|
9.3.2 xtable for LaTeX and HTML |
|
|
178 | (3) |
|
9.3.3 texreg for LaTeX and HTML |
|
|
181 | (3) |
|
9.3.4 Fitting Large Tables in LaTeX |
|
|
184 | (1) |
|
9.3.5 xtable with non-supported class objects |
|
|
185 | (3) |
|
9.3.6 Creating variable description documents with xtable |
|
|
188 | (3) |
|
10 Showing Results with Figures |
|
|
191 | (22) |
|
10.1 Including Non-knitted Graphics |
|
|
191 | (4) |
|
10.1.1 Including graphics in LaTeX |
|
|
192 | (2) |
|
10.1.2 Including graphics in Markdown/HTML |
|
|
194 | (1) |
|
10.2 Basic knitr/rmarkdown Figure Options |
|
|
195 | (2) |
|
|
195 | (1) |
|
|
196 | (1) |
|
10.3 Knitting R's Default Graphics |
|
|
197 | (3) |
|
10.4 Including ggplot2 Graphics |
|
|
200 | (9) |
|
10.4.1 Showing regression results with caterpillar plots |
|
|
204 | (5) |
|
10.5 JavaScript Graphs with googleVis |
|
|
209 | (6) |
|
10.5.1 JavaScript Graphs with htmlwidgets-based packages |
|
|
212 | (1) |
IV Presentation Documents |
|
213 | (64) |
|
11 Presenting with knitr/LaTeX |
|
|
215 | (22) |
|
|
215 | (10) |
|
11.1.1 Getting started with LaTeX editors |
|
|
216 | (1) |
|
11.1.2 Basic LaTeX command syntax |
|
|
216 | (1) |
|
11.1.3 The LaTeX preamble & body |
|
|
217 | (3) |
|
|
220 | (1) |
|
11.1.5 Paragraphs & spacing |
|
|
221 | (1) |
|
|
221 | (1) |
|
|
221 | (2) |
|
|
223 | (1) |
|
|
224 | (1) |
|
|
225 | (1) |
|
|
225 | (1) |
|
11.2 Bibliographies with BibTeX |
|
|
225 | (5) |
|
|
225 | (2) |
|
11.2.2 Including citations in LaTeX documents |
|
|
227 | (1) |
|
11.2.3 Generating a BibTeX file of R package citations |
|
|
227 | (3) |
|
11.3 Presentations with LaTeX Beamer |
|
|
230 | (7) |
|
|
231 | (3) |
|
11.3.2 knitr with LaTeX slideshows |
|
|
234 | (3) |
|
12 Large knitr/LaTeX Documents: Theses, Books, and Batch Reports |
|
|
237 | (12) |
|
12.1 Planning Large Documents |
|
|
237 | (1) |
|
12.2 Large Documents with Traditional LaTeX |
|
|
238 | (3) |
|
12.2.1 Inputting/including children |
|
|
239 | (1) |
|
12.2.2 Other common features of large documents |
|
|
240 | (1) |
|
12.3 knitr and Large Documents |
|
|
241 | (2) |
|
12.3.1 The parent document |
|
|
241 | (1) |
|
12.3.2 Knitting child documents |
|
|
242 | (1) |
|
12.4 Child Documents in a Different Markup Language |
|
|
243 | (1) |
|
12.5 Creating Batch Reports |
|
|
244 | (5) |
|
13 Presenting on the Web and Other Formats with R Markdown |
|
|
249 | (22) |
|
|
249 | (7) |
|
13.1.1 Getting started with Markdown editors |
|
|
250 | (1) |
|
13.1.2 Preamble and document structure |
|
|
250 | (2) |
|
|
252 | (1) |
|
|
253 | (1) |
|
13.1.5 Paragraphs and new lines |
|
|
253 | (1) |
|
|
254 | (1) |
|
|
254 | (1) |
|
13.1.8 Special characters and font customization |
|
|
254 | (1) |
|
|
254 | (1) |
|
13.1.10 Escape characters |
|
|
255 | (1) |
|
13.1.11 Math with MathJax |
|
|
255 | (1) |
|
13.2 Further Customizability with rmarkdown |
|
|
256 | (5) |
|
13.2.1 More on rmarkdown Headers |
|
|
256 | (4) |
|
13.2.2 CSS style files and Markdown |
|
|
260 | (1) |
|
13.3 Slideshows with Markdown, rmarkdown, and HTML |
|
|
261 | (7) |
|
13.3.1 HTML Slideshows with rmarkdown |
|
|
262 | (2) |
|
13.3.2 LaTeX Beamer Slideshows with rmarkdown |
|
|
264 | (1) |
|
13.3.3 Slideshows with Markdown and RStudio's R Presentations |
|
|
265 | (3) |
|
13.4 Publishing HTML Documents Created by R Markdown |
|
|
268 | (3) |
|
13.4.1 Standalone HTML files |
|
|
268 | (1) |
|
13.4.2 Hosting webpages with Dropbox |
|
|
268 | (1) |
|
|
269 | (1) |
|
13.4.4 Further information on R Markdown |
|
|
270 | (1) |
|
|
271 | (6) |
|
14.1 Citing Reproducible Research |
|
|
271 | (2) |
|
14.2 Licensing Your Reproducible Research |
|
|
273 | (1) |
|
14.3 Sharing Your Code in Packages |
|
|
273 | (1) |
|
14.4 Project Development: Public or Private? |
|
|
274 | (1) |
|
14.5 Is it Possible to Completely Future-Proof Your Research? |
|
|
275 | (2) |
Bibliography |
|
277 | (8) |
Index |
|
285 | |