Reproducible Research with R

Reni Kaul & Deven Gokhale & Zane Billings
2022-06-06

About Myself

  • Epi/Bios PhD student with Andreas Handel.
  • I use data analysis and statistical models to study epidemiology and immunology of flu and norovirus.
  • I started using R and R Markdown in 2017.
  • I use R in my research to:
    • organize data
    • visualize results
    • fit models
    • write reproducible manuscripts
    • pretty much everything I do is in R (Markdown), actually.
  • You can get my contact info at https://wzbillings.com. My office is on the HSC so feel free to take the bus, or just email me. I'm happy to answer any R questions. (Or questions about grad school, or anything else that might help!)

Outline

At the end of this workshop you should be able to…

  • code using best practices
  • create an HTML doc with code and commentary
  • write a function
  • create and use scripts
  • calculate summary and inferential statistics of a dataset
  • create a figure from data

Topics

  1. Introduction to reproducible research
  2. Review of tidyverse

    Break

  3. Explore data using a R project

  4. Automating data analysis with functions

  5. Using scripts in your workflow

  6. Wrap Up

THE VERY FIRST THING WE ARE GOING TO DO.

  • Open R on your computer.
  • Run install.packages("usethis") to install the usethis package.
  • Run the command usethis::use_blank_slate(). If successful, it should print a message.
  • I recommend you do this first thing every time you set up R on a new computer and every time you update R.
  • We'll talk about why I had you do this in a bit :)

Other RR recommendations

  • We have barely scratched the surface of reproducible research!
  • Especially if you are new to programming, this is a GREAT place to start, and if you follow these tips, your code will be well above average.
  • If you are an experienced programmer, you may be interested in looking into Git/GitHub, renv, targets, and inline R coding for Markdown files. Using these packages, you can automate and future-proof an entire project so that it “just works” when someone else downloads it.
  • We covered a lot today and you should be proud of yourself! Please contact me with any questions!!!

6. Wrap Up

We can…

  • code using best practices
  • create an HTML doc with code and commentary
  • write a function
  • create and use scripts
  • calculate summary statistics of a dataset
  • create a figure from data

W2

Reminder: complete project worksheet

6. Wrap Up

Next

  • Modeling
    • simulating data
    • fitting models to data

W3