Formatting your code

Formatting our code so it is easy to read, follow and reproduce is an important part of open-access science and helpful when sharing our code to collaborators or friends. It can also be useful when we look back at a past script to remember how to do something.

Before we start explaining some of this, download and look at the R Markdown Reference Guide.

This will help if ever you wish to produce a word, pdf or html document directly from your markdown document (which is how I made these tutorials).

This section is dedicated to formatting and setting up your R scripts/markdown. We will cover some useful tips for setting up your code in an easy to read and reproducable manner and then cover the process of converting your code into a word, html and pdf document (aka knitting).