<- c(
pkgs "readr", "dplyr", "forcats", "forestmodel",
"ggcorrplot", "ggplot2", "gt", "gtsummary", "lintr", "styler",
"reprex"
)install.packages(pkgs)
Welcome!
Welcome to the Writing Better R Code workshop! The course website can be found at nrennie.rbind.io/training-better-r-code, where you will also find a copy of the slides.
Contents
It can feel like a big jump to go from learning R in a taught module, to using R for research projects in the real world. You might be starting to write scripts that are becoming endlessly long, you might have lots of different R scripts, or you might be struggling to understand the code you wrote six months ago. When you ask for feedback from colleagues or supervisors, you might end up with scripts called code_final.R
and then code_final_v2.R
. If any of this sounds familiar, then this course is for you. In this workshop, you’ll learn tips and tricks to write better R code that is easier to read, manage, and share with others. In this workshop, we’ll cover:
- R projects
- Linting and styling code
- Organising R scripts
- Dealing with code that depends on other things
Prerequisites
Please bring a laptop (and charger). The workshop assumes you have a (reasonably recent version of) R and RStudio installed on your laptop.
Ideally, you will have registered for a GitHub account at https://github.com/ before you attend the session. There’s some advice on choosing a username here: https://happygitwithr.com/github-acct#username-advice. If you do not already have Git installed on your laptop, please install it before the session. See https://happygitwithr.com/install-git#install-git for instructions (or use AppsAnywhere).
R packages
There’s no need to install these before the session, but we’ll be using the following R packages:
- readr
- dplyr
- forcats
- forestmodel
- ggcorrplot
- ggplot2
- gt
- gtsummary
- lintr
- styler
- reprex
The workshop materials for the session on collaborating on code with Git and GitHub for R users can be found at nrennie.rbind.io/training-git-r.
View other available training courses and workshops at nrennie.rbind.io/projects/training-workshops.