Analytical Coding Guide
This site provides the Cabinet Office Analysis & Insight team’s guide for coding in analytical projects.
The purpose of this guide is to provide simple advice about how to use code in our analysis. It is broken down into three sections: workflow, style and output. This site is a ‘living document’ that will evolve as our approach develops/changes. While the guide is intended to be language independent, given our practice examples are more likely to be based on using R or R Studio. Our approach to coding and analysis is particularly influenced by the Tidyverse.
This guide isn’t designed to provide a rulebook of ‘hard’ standards that must be followed, rather it provides advice and general guidelines to using code in analytical projects. There are many other guides and resources developed by others, which provide more detailed information and have influenced this guide to more o. Each person and team also have their own individual style and perferences - this guide is designed to provide some common building blocks so that it is easier for our analysts to work together when coding.
Our workflow guidelines set out how you should structure and manage code in an analytical project.
- Project-based working
- Functional programming
- Dependency management
- Version control (git)
- QA and code review
Our style guidelines set out how to write code for a project.
- Naming conventions
- Code Flow
- Comments and documentation
- Error messages
Our output guidelines set out some principles for presenting results.
- Slide decks