UFRGS/EA
2021-10-27
the intellectual and practical activity encompassing the systematic study of the structure and behaviour of the physical and natural world through observation and experiment. Oxford English Dictionary
However, academic research is usually conducted in a black-box fashion:
Governance and reproducibility!
All data and code should be shared and reproducible with popular programming languages
Prevalence of academic governance and self-audit
If particular results are not reproducible, be transparent about it and retract if needed
Version control (data & code)
Git (GitHub and friends)
Cloud backup and infrastructure (Dropbox/Google Drive/OneDrive)
R offers a range of tools for keeping your code reproducible:
Project organization (files and folders)
Package version:
checkpoint
renv
Containerization with Docker
All R scripts numbered sequentially (import \(\rightarrow\) clean \(\rightarrow\) EDA \(\rightarrow\) model)
Extra files and output in their own folder
Think of a research project as a R package, with its own folder structure
A real life Example:
renvInspired in Python’s venv,
renvmaintains records of all packages used within a project (similar to Python) and provides infrastructure for recording and restoring packages.
How to use:
Install renv in R, set path to project folder (or open RStudio project file) and initialize with renv::init()
Record packages with renv::snapshot()
Restore (if needed) packages with renv::restore()
checkpointPackage
checkpointis an initiative from Microsoft to keep R code reproducible.
Unlike
renvthat finds packages from project,checkpointuses time to set package versions and (slowly) create a private package repository.
How to use:
Install checkpoint, set a date you want to reach out
Go back in time with checkpoint('2019-01-01')
Containers are modular virtual environments that freeze a particular computer setup, mostly used in cloud computing.
Containers are the state-of-the-art for code execution and reproducibility (guarantees a particular architecture, forever).
For R users, containers are mostly used in deploying Shiny applications.
All code and data available at GitHub