Scientific reproducibility: What is it for?
|
Reproducible research is key for scientific advancement.
RStudio can help you to organize, have better control over and produce reproducible research.
|
Navigating RStudio and R Markdown Documents
|
RStudio has four panes to organize your code and environment.
Manage packages in RStudio using specific functions.
R Markdown documents combine text and code.
|
Introduction to Working with R Markdown Files
|
An R Markdown file is comprised of a YAML header, formatted text in Rmd and code chunks.
The knit function renders the file into the chosen output format.
Rstudio has some journals’ templates that can save you some formatting time or you can make your own for frequent submissions.
|
Good Practices for Managing Projects in RStudio
|
Use best practices for file and folder organization. This includes using relative file paths as opposed to complete file paths.
Make sure that all data are backed up on multiple devices and that you treat raw data as read-only.
We can use Git and Github to keep track of what we’ve done in the past, and what we plan to do in the future.
Rproj files are pivotal to keeping everything bundled and organized.
|
Getting Your project set up with Version Control in RStudio
|
R Studio has Git version control functionality built in.
Forking a Github repository makes a copy of the repository into your personal account on Github.
You can clone a git repository from Github to your local disk using R Studio.
For this workshop each learner will work with their own fork of the “R-Repro-pub” repository.
|
Writing and Styling Rmd Documents
|
The visual editor has made formatting much easier.
You can apply Rmd styling without prior R Markdown knowledge.
You can include inline code to narratives for basic calculations and dynamic information.
|
Adding Code-Generated Plots and Figures
|
Knitr will render your code and R markdown-formatted text and output your document format of choice
Code chunks are runable piece of R code. Each time you knit the document, calculations and plots will be run and displayed
Options for code chunks can be set at the individual level or at the global level
|
Reproducible & Efficient Methods of Using Code Chunks
|
Learn how to externally source code source()
Learn how to modularize your code to make it more reproducible
There are options for changing the working directory of your .rmd document with package rprojroot
Use a chunk at the beginning of your document to load libraries and data globally to make your document more effiecient.
|
Bibliography, Citations & Cross-Referencing
|
Rstudio supports different lookups strategies to easy the citation process.
Rstudio supports different citation styles.
The YAML can be ajusted to display uncited items in the reference list.
Use bookdown to cross-reference content.
|
Collaborating via Github
|
Setting up R Studio to authenticate with Github using a Personal Authentication Token (PAT).
Setting the Git repository Origin in your R Studio project enables pushing and pulling from your local copy of the repository to the repository on Github.
|
Publishing your project
|
You may choose to share and publish your data project before publishing its associated manuscript.
Sharing the code, data and documentation is necessary to allow for inspection and research reproducibility.
|