Setting up your workspace

There are very quick ways to open R and begin coding, however, having an organised, well-structured working directory in your computer can save you hours of hassle and make your code much easier to share. As biology and data science are becoming increasingly complex many are turning to computer intensive, coding based software (like you!). With this movement in data science and open access, having our code reproducible, transparent and understandable is key. So why not start off like that.

The first part of this tutorial follows many practices outlined in the fantastic “Guide to Reproducible Code in Ecology and Evolution” from the British Ecological Society. I strongly recommend reading this at some stage.

File system

Before we jump into R, we are going to create a clean and managable folder system.

Create a new folder in a location of your choosing (e.g. My Documents or Desktop) called R-tutorials

This can be named anything you like, but try to keep it relevant and understandable (for future you).

In this new folder, create a series of new folders called:
- data
- doc
- figs
- output
- R

Here is the basic outline for these folders:
  • The data folder if where you store your raw/input data
  • The doc folder is where you store the manuscript for the project
  • The figs folder is where all of your figures will be stored from the analyses
  • The output folder is where you keep any intermediate datasets generated by your analysis, result reports etc.
  • The R folder is pretty self-explanatory but it is where we will store all of our R scripts, notebooks etc.

Now, let’s move on to the next step.