2 Code in style


Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread


code qulaity xkcd 1513
code qulaity xkcd 1513

2.1 R Tidyverse

At Lawernson Lab , we heavily use Tidyverse packages to manipulate and visualize our data, so it is logical to use the tidyverse style guide for a seamless experience.These are some highlight from the style guides.

  • File names should be meaningful and end in .R. Avoid using special characters in file names - stick with numbers, letters, -, and _
  • Variable and function names should use only lowercase letters, numbers, and . Use underscores () (so called snake case) to separate words within a name
  • Try to use verbs for function names
  • Only use return() for early returns. Otherwise, rely on R to return the result of the last evaluated expression.
  • Use %>% to emphasise a sequence of actions, rather than the object that the actions are being performed on.