Your working directory is the folder you’re working in or the folder that holds the file that you have open.
Let’s say you create a folder on your
BIOL-125/ to hold all of your coursework for this class. And in it you have another folder for your research project–
Research-Project/–in which you have a Word file for keeping notes–
A directory map would now look something like the following:
├── Users/ │ ├── yourUserName/ │ │ ├── Downloads/ │ │ ├── Documents/ │ │ ├── Desktop/ │ │ | ├── BIOL-125 │ │ | | ├── Research-Project/ │ │ | | | ├── biol-125_research-project_notes.docx
When you open your
Research_Project/ folder, we call this your working directory–the directory that holds the files that you are currently working with, or that you currently have access to. If you clicked on your
Desktop/, your working directory would switch to your
Desktop/, since we know that your
Desktop/ is just another folder.
This has implications for how the applications that you work with access the files on your computer. If you opened your file
Research-Project would not only be your working directory, it would be Microsoft Word’s working directory for that file. With
biol-125_research-project_notes.docx open, if you went to
File > Open... in Word, it would prompt you to open a file in the directory
Research-Project, because this is where the application is looking for working files.
Generally, in day to day life, we don’t need to worry about things like working directories. When we conduct research though, and we use tools like
R, working directories–and knowing where directories and files are in relation to the directory that you are currently in–have significant implications for how things work and for computational reproducibility.
In the next section, we’ll look at common directory structures used to organize research. For the moment, we’ll assume that you have a research project and that associated with that research project you have data and that you’re analyzing that data, and that you’re using two different folders to hold the files associated with these activities. So a map something like the following:
├── Users/ │ ├── yourUserName/ │ │ ├── Downloads/ │ │ ├── Documents/ │ │ ├── Desktop/ │ │ | ├── BIOL-125 │ │ | | ├── Research-Project/ │ │ | | | ├── Data/ │ │ | | | ├── Analysis/ │ │ | | | ├── biol-125_research-project_notes.docx
If you have a file in your
Analysis/ folder open,
Analysis/ is your working directory. If this file needs to access a file with data in your
Data/ directory, you need to be explicit about where this file lives–it lives up one level in the hierarchy in another folder called