knitr::opts_chunk$set(echo = FALSE)

Workshop overview

Motivation

This image was created by Scriberia for The Turing Way community and is used under a CC-BY licence (DOI 10.5281/zenodo.3332807).{width=50%}

Two main topics

Motivations for a better project organization and workflow

  • Reproduciblity 🔃 (for you and others)
  • Reliablity 🏋 (will it work again?)
  • Re-usablity ⚙ (don't re-invent the wheel)
  • Visiblity 🔍 (let others see and use your work)

How? Use a research compendium!

This image was created by Scriberia for The Turing Way community and is used under a CC-BY licence (DOI 10.5281/zenodo.3332807).{width=50%}


What is a research compendium?

This is a collection of all digital parts of a research project including data, code, texts (protocols, reports, questionnaires, metadata). The collection is created in such a way that reproducing all results is straight forward.

(Definition from The Turing Way)

Excursion to the TTW website

Excursion to Karthik Ram's talk at RStudio::conf 2019


Mavick et al. 2018{width=30%}


{width=100%}


Advantages of using R Packages

Hands-on I

Create a research compendium with the R package structure

Version control

{width=40%}

Git as a distributed version control system (VCS)

Hands-on II

Add version control to the research compendium

Automated testing

What?

  • unit tests: functions that run a small amount of code: "units"
  • input: defined and fixed
  • compares output with an expected output
  • returns true/false

Why?

  • fewer bugs
  • better code (needs to be testable)
  • confidence and trust

How?

  • write tests either before or after implementing your code
  • when you found a bug: before fixing, write a test that would have detected it
  • use a test framework, e.g. in R: testthat package (Hadley Wickham)

Hands-on III

Unit tests

Continous integration (CI)

"If it hurts, do it more often" (Martin Fowler)

Continous integration (CI)

Idea

  • shared code repository (e.g. on github)
  • push code frequently (every day)
  • automated builds and tests after each commit
  • immediate feedback if something doesn't work anymore
  • however, can be time consuming and might be overkill for small or solo projects

Github Actions for CI (and other automation tasks)

  • supports mac-OS, windows, linux, docker containers
  • integration with github, so no separate setup and authentication
  • free for open source, academic or educational repos
  • 20 concurrent jobs (40 with pro), 6 h per job, 72 h per workflow
  • self host to remove the per job limit
  • very easy to setup with R using the usethis package

This image was created by Scriberia for The Turing Way community and is used under a CC-BY licence (DOI 10.5281/zenodo.3332807).{width=20%}

Hands-on IV

Github Actions for R CMD check

Reproducibility and Accessability

Another excursion to Karthik Ram's talk at RStudio::conf 2019

Holepunch

Hands-on V

Publish your repository on Binder with a live RStudio server instance



selinaZitrone/YoMos2020 documentation built on June 29, 2021, 2:08 p.m.