diff --git a/vignettes/07_reproducable_research.Rmd b/vignettes/07_reproducable_research.Rmd index d278826..bbc67ad 100644 --- a/vignettes/07_reproducable_research.Rmd +++ b/vignettes/07_reproducable_research.Rmd @@ -1,5 +1,5 @@ --- -title: "A Biostatistician's Introduction to Reproducible Research and Reporting" +title: "Introduction to Reproducible Research and Reporting" author: "Paul Stevenson" date: "`r format(Sys.time(), '%d %B %Y')`" output: @@ -18,6 +18,9 @@ vignette: > ```{r init, include = FALSE, echo = FALSE} library(biometrics) +library(knitr) + +source("assets/R/hooks.R") ``` @@ -32,19 +35,19 @@ library(biometrics)
- - Convention for how you organise your research artefacts into directories - - A standard and easily recognisable way for organising a reproducible research project - - Simplifies file management and streamlines analytical workflows - - Ideal for projects that result in the publication of a paper - - Easier to communicate your work with other researchers (and your future self) - - "Project as a Package" - - R and beyond +- Convention for how you organise your research artefacts into directories +- A standard and easily recognisable way for organising a reproducible research project +- Simplifies file management and streamlines analytical workflows +- Ideal for projects that result in the publication of a paper +- Easier to communicate your work with other researchers (and your future self) +- "Project as a Package" +- R and beyond
  -
[https://github.com/ropensci/rrrpkg](https://github.com/ropensci/rrrpkg)
+
## Definition @@ -55,24 +58,24 @@ library(biometrics)
- >- Convention for how you organise your research artefacts into directories - >- A standard and easily recognisable way for organising a reproducible research project - >- Simplifies file management and streamlines analytical workflows - >- Ideal for projects that result in the publication of a paper - >- Easier to communicate your work with other researchers (and your future self) - >- "Project as a Package" - >- R and beyond +>- Convention for how you organise your research artefacts into directories +>- A standard and easily recognisable way for organising a reproducible research project +>- Simplifies file management and streamlines analytical workflows +>- Ideal for projects that result in the publication of a paper +>- Easier to communicate your work with other researchers (and your future self) +>- "Project as a Package" +>- R and beyond
  -
[https://github.com/ropensci/rrrpkg](https://github.com/ropensci/rrrpkg)
+
## Example Project Directory | *The Container* -```{r, echo = F, out.extra = "class='centre'", out.width = "50%"} -knitr::include_graphics(file.path("assets", "images", "Slide1.JPG")) +```{r, echo = F, out.extra = "figure", out.width = "50%"} +knitr::include_graphics(file.path("assets", "images", "07_Slide1.JPG")) ``` @@ -80,93 +83,94 @@ knitr::include_graphics(file.path("assets", "images", "Slide1.JPG")) ## Project meta data - >- README.md - >- a synopsis of the project - >- very useful for your future self and colleges/collaborators - - >- NEWS.md - >- Communicate change to the project files/data - - >- DESCRIPTION (R specific - Python requirements.txt) - >- LICENSE - >- .gitIgnore (Will talk about Git later) +>- README.md + >- a synopsis of the project + >- very useful for your future self and colleges/collaborators + +>- NEWS.md + >- Communicate change to the project files/data + +>- DESCRIPTION (R specific - Python requirements.txt) +>- LICENSE +>- .gitIgnore (Will talk about Git later) # Project Administration ## Project Administration -```{r, echo = F, out.extra = "class='centre'", out.width = "50%"} -knitr::include_graphics(file.path("assets", "images", "Slide2.JPG")) +```{r, echo = F, out.extra = "figure", out.width = "50%"} +knitr::include_graphics(file.path("assets", "images", "07_Slide2.JPG")) ``` ## admin \* - - Project meta data - - Legal documents (e.g. contracts) - - Communications - - Ethics documentation - - Indirect resources (e.g. papers) - - Project management resources - - etc. +- Project meta data +- Legal documents (e.g. contracts) +- Communications +- Ethics documentation +- Indirect resources (e.g. papers) +- Project management resources +- etc. -\* I Would consider adding directories/files marked with an asterisk to .gitIgnore +\* Consider adding directories/files marked with an asterisk to .gitIgnore ## archive \* - - Old code that might be redundant, but is precious - - Helps to keep project folders tidy +- Old code that might be redundant, but is precious +- Helps to keep project folders tidy # Data Directories ## Data Directories -```{r, echo = F, out.extra = "class='centre'", out.width = "50%"} -knitr::include_graphics(file.path("assets", "images", "Slide3.JPG")) +```{r, echo = F, out.extra = "figure", out.width = "50%"} +knitr::include_graphics(file.path("assets", "images", "07_Slide3.JPG")) ``` ## data-raw \* - - a "read-only" directory to store raw data (e.g. Excel, STATA, SAS, .csv) - - recommend changing the file to read only in operating system - - The heart of reproducible research, all actions are traceable from raw data to report +- A "read-only" directory to store raw data (e.g. Excel, STATA, SAS, .csv) +- Recommend changing the file to read only in operating system +- The heart of reproducible research, all actions are traceable from raw data to report ## data \* - - Data is converted from the raw format in to the software's preferred structure (e.g. .RData, .rds) - - Minimal operations are performed on data - - correcting variable names - - data cleaning - - data harmonisation/standardisation/coding - - table joining/splitting +- Data is converted from the raw format in to the software's preferred structure (e.g. .RData, .rds) +- Minimal operations are performed on data + - correcting variable names + - data cleaning + - data harmonisation/standardisation/coding + - table joining/splitting ## cache \* - >- Store manipulated data here for statistical analysis +>- Store manipulated data here for statistical analysis # Script/Algorithm Directories ## Script/Algorithm Directories -```{r, echo = F, out.extra = "class='centre'", out.width = "50%"} -knitr::include_graphics(file.path("assets", "images", "Slide4.JPG")) +```{r, echo = F, out.extra = "figure", out.width = "50%"} +knitr::include_graphics(file.path("assets", "images", "07_Slide4.JPG")) ``` ## ProjectTemplate Package - >- Automates data initiation - >- Loads library - >- Runs munge scripts - >- Loads data +```{r eval = F} +library('ProjectTemplate') +load.project() + +``` - >- +>- Automates data initiation + >- Loads library + >- Runs munge scripts + >- Loads data - -library('ProjectTemplate')
-load.project() -
+>- ## munge @@ -176,41 +180,41 @@ load.project()
www.dictionary.com
- - A ProjectTemplate directory - - Order numerically in the order the scripts should be run: - - 01-munge.R - - 02-Lexis.R +- A ProjectTemplate directory +- Order numerically in the order the scripts should be run: + - 01-munge.R + - 02-Lexis.R ## R | (src, py, cpp, or whatever) - - 00-cleaner.R - read in raw data and save in data - - 01-main.R - main script file - - 99-helper.R - custom functions to be read in at start of script - - data.R - How you can create a data dictionary in R! +- 00-cleaner.R - read in raw data and save in data +- 01-main.R - main script file +- 99-helper.R - custom functions to be read in at start of script +- data.R - How you can create a data dictionary in R! ## Other Directories - - config - - ProjectTemplate configuration files, e.g.: - - Auto-munge - - Auto-load packages - - Auto-import cache/data - - inst - - Auto generated files used by some package-related functions - - Vignettes +- config + - ProjectTemplate configuration files, e.g.: + - Auto-munge + - Auto-load packages + - Auto-import cache/data +- inst + - Auto generated files used by some package-related functions + - Vignettes -## Other Possibilities +## More Directory Ideas
- - shiny - - docker - - logs - - diagnostics - - man/doc - - graphs - - tests - - reports/vignettes +- shiny +- docker +- logs +- diagnostics +- man/doc +- graphs +- tests +- reports/vignettes
@@ -218,8 +222,8 @@ load.project() ## Reporting -```{r, echo = F, out.extra = "class='centre'", out.width = "50%"} -knitr::include_graphics(file.path("assets", "images", "Slide5.JPG")) +```{r, echo = F, out.extra = "figure", out.width = "50%"} +knitr::include_graphics(file.path("assets", "images", "07_Slide5.JPG")) ``` @@ -237,8 +241,8 @@ knitr::include_graphics(file.path("assets", "images", "Slide5.JPG"))
-```{r, echo = F, out.extra = "class='centre'", out.width = "15%"} -knitr::include_graphics(file.path("assets", "images", "rmarkdown.png")) +```{r, echo = F, out.extra = "figure", out.width = "15%"} +knitr::include_graphics(file.path("assets", "images", "07_rmarkdown.png")) ``` @@ -253,23 +257,23 @@ Live demo ## Version Control

-```{r, echo = F, out.extra = "class='centre'", out.width = "75%"} -knitr::include_graphics(file.path("assets", "images", "github_logo.png")) +```{r, echo = F, out.extra = "figure", out.width = "75%"} +knitr::include_graphics(file.path("assets", "images", "07_github_logo.png")) ``` -```{r, echo = F, out.extra = "class='centre'", out.width = "75%"} -knitr::include_graphics(file.path("assets", "images", "gitlab.png")) +```{r, echo = F, out.extra = "figure", out.width = "75%"} +knitr::include_graphics(file.path("assets", "images", "07_gitlab.png")) ``` -```{r, echo = F, out.extra = "class='centre'", out.width = "75%"} -knitr::include_graphics(file.path("assets", "images", "logos__Bitbucket.png")) +```{r, echo = F, out.extra = "figure", out.width = "75%"} +knitr::include_graphics(file.path("assets", "images", "07_logos__Bitbucket.png")) ``` -```{r, echo = F, out.extra = "class='centre'", out.width = "75%"} -knitr::include_graphics(file.path("assets", "images", "cran.png")) +```{r, echo = F, out.extra = "figure", out.width = "75%"} +knitr::include_graphics(file.path("assets", "images", "07_cran.png")) ``` @@ -279,21 +283,21 @@ knitr::include_graphics(file.path("assets", "images", "cran.png")) ## Coding Tips - - Be consistent: - - Values: - - "day1" vs "day_1" vs "Day 1" - - "5th May 1970" vs "01-05-1970" vs "05/01/1970" vs 1970/05/01 - - Variables: - - FirstName vs first_name - - sex vs female - - Use variable names that a human can understand - - Document/comment your code! +- Be consistent: + - Values: + - "day1" vs "day_1" vs "Day 1" + - "5th May 1970" vs "01-05-1970" vs "05/01/1970" vs 1970/05/01 + - Variables: + - FirstName vs first_name + - sex vs female +- Use variable names that a human can understand +- Document/comment your code! ## Useful Tools/Packages - >- R Studio IDE - >- Tidyverse - data wrangling and visualisation - >- repmis: Miscellaneous Tools for Reproducible Research - >- captioner: Store figure and table captions and print them later - >- devtools - >- Telethon Kids Biometrics package +>- R Studio IDE +>- Tidyverse - data wrangling and visualisation +>- repmis: Miscellaneous Tools for Reproducible Research +>- captioner: Store figure and table captions and print them later +>- devtools +>- Telethon Kids Biometrics package diff --git a/vignettes/assets/images/Slide1.JPG b/vignettes/assets/images/07_Slide1.JPG similarity index 100% rename from vignettes/assets/images/Slide1.JPG rename to vignettes/assets/images/07_Slide1.JPG diff --git a/vignettes/assets/images/Slide2.JPG b/vignettes/assets/images/07_Slide2.JPG similarity index 100% rename from vignettes/assets/images/Slide2.JPG rename to vignettes/assets/images/07_Slide2.JPG diff --git a/vignettes/assets/images/Slide3.JPG b/vignettes/assets/images/07_Slide3.JPG similarity index 100% rename from vignettes/assets/images/Slide3.JPG rename to vignettes/assets/images/07_Slide3.JPG diff --git a/vignettes/assets/images/Slide4.JPG b/vignettes/assets/images/07_Slide4.JPG similarity index 100% rename from vignettes/assets/images/Slide4.JPG rename to vignettes/assets/images/07_Slide4.JPG diff --git a/vignettes/assets/images/Slide5.JPG b/vignettes/assets/images/07_Slide5.JPG similarity index 100% rename from vignettes/assets/images/Slide5.JPG rename to vignettes/assets/images/07_Slide5.JPG diff --git a/vignettes/assets/images/cran.png b/vignettes/assets/images/07_cran.png similarity index 100% rename from vignettes/assets/images/cran.png rename to vignettes/assets/images/07_cran.png diff --git a/vignettes/assets/images/devtools.png b/vignettes/assets/images/07_devtools.png similarity index 100% rename from vignettes/assets/images/devtools.png rename to vignettes/assets/images/07_devtools.png diff --git a/vignettes/assets/images/directory.JPG b/vignettes/assets/images/07_directory.JPG similarity index 100% rename from vignettes/assets/images/directory.JPG rename to vignettes/assets/images/07_directory.JPG diff --git a/vignettes/assets/images/github_logo.png b/vignettes/assets/images/07_github_logo.png similarity index 100% rename from vignettes/assets/images/github_logo.png rename to vignettes/assets/images/07_github_logo.png diff --git a/vignettes/assets/images/gitlab.png b/vignettes/assets/images/07_gitlab.png similarity index 100% rename from vignettes/assets/images/gitlab.png rename to vignettes/assets/images/07_gitlab.png diff --git a/vignettes/assets/images/logos__Bitbucket.png b/vignettes/assets/images/07_logos__Bitbucket.png similarity index 100% rename from vignettes/assets/images/logos__Bitbucket.png rename to vignettes/assets/images/07_logos__Bitbucket.png diff --git a/vignettes/assets/images/rmarkdown.png b/vignettes/assets/images/07_rmarkdown.png similarity index 100% rename from vignettes/assets/images/rmarkdown.png rename to vignettes/assets/images/07_rmarkdown.png diff --git a/vignettes/assets/images/rstudio.png b/vignettes/assets/images/07_rstudio.png similarity index 100% rename from vignettes/assets/images/rstudio.png rename to vignettes/assets/images/07_rstudio.png