Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 3.07 KB

R.md

File metadata and controls

26 lines (19 loc) · 3.07 KB

R Resources

This page contains information which the Transforming Publishing team think will be useful to analysts using R in their work in PHS. The contents cover coding style, RStudio projects and the tidyverse. For a comprehensive collection of resources for using R in PHS please visit this site.

R Coding Style

The R style guide for PHS analysts is available in the PHS R-Resources repo. Analysts should follow these guidelines as closely as possible as we strive to achieve code that is reproducible, shareable and efficient (our new mantra 🙏). The style guide should be seen as an evolving document, so please share any thoughts you have about how to improve it and keep an eye on it for updates.

The tidyverse style guide by Hadley Wickham should be used in conjunction with the PHS style guide. This is a comprehensive style guide covering object names, spacing, assignment (<- not = being another of our mantras), functions, the pipe operator %>% and much more.

RStudio projects

RStudio projects are a great way to keep your R work well organised, and to enable the use of version control methods such as Git. A brief introduction to projects by RStudio can be found here and a more comprehensive guide to project orientated workflows has been written by Jenny Bryan and Jim Hester. A new project which follows the recommended structure within PHS can be created using the phstemplates package. There is also a blank R Shiny app template available to download and use on the PHS GitHub account.

Tidyverse

Tidyverse is a suite of R packages for data manipulation and visualisation. The tidyverse style of coding is recommended within the TPP team. RStudio have published a number of cheatsheets which are useful when using the tidyverse. A few videos from the tidyverse wizard (Hadley Wickham) himself:

eBooks

Local R community