16 Introduction

Written by Rohan Alexander and last updated on 7 October 2021.

When you first learn how to code in R, it can feel like you’re in a battle to just get something working, without regard for what it looks like. That fine initially, but as you start to use R in more involved settings that approach will become a bit chaotic. This will result in you having to do more work in the long run.

In this module we cover how to hold back that chaos. While they will add a few minutes initially, the techniques that we cover here will save you time in the long run. Your analysis will be better and more professional, and it will be easier for you to build on the code base that you establish every time you code.

This is a somewhat bitty module. We’ve been fairly prescriptive here, but you should think of it more as a default to get you started, and you can move from this default as you think best. First we discuss R Projects, and then how to structure your folders. We then discuss writing comments, which makes your code more useful for other people (even if that person is just future-you). Then we cover installing and loading packages, which are collections of other people’s code. Finally, we discuss loading data.

We got the sharks out of the pool - feel free to jump in!