The two ways of using relative directories in an R project

Опубликовано: 02 Сентябрь 2026
на канале: Hannes Datta
184
1

When collaborating on empirical research projects, one needs to ensure the code runs on all computers that are used in a team. One of the most common mistakes in starting up a collaborative research project is by defining "absolute" directory names in your R script, e.g., with read.csv("C:/users/Hannes/dataset.csv"). Such a project won't run on other computers, because likely the project will reside in a different directory, and the data set cannot be found. Relative directories are a solution to this problem. Rather than defining an "absolute" path, one defines all files and directories RELATIVE to (a) your main project directory, or (b) the exact location where a source file is located. While this difference may be subtle, in practice, it causes a lot of problems. In this video, I explain the difference between these two ways of defining relative directories. The video was recorded as part of my course "Data Preparation and Workflow Management". Check out the course page for more info + all study material (https://dprep.hannesdatta.com).