Appendix A — Basic computer literacy

A.1 Files, folder and file extensions
Files saved on your computer live in a specific place. For example, if you download a file from a browser (like Google Chrome, Safari or Firefox), the file is normally saved in the Download folder. But where does the Download folder live? Usually, in your user folder! The user folder normally is the name of your account or a name you picked when you created your computer account. In my case, my user folder is simply called ste.
So, let’s assume I download a file, let’s say big_data.csv, in the Download folder of my user folder. Now we can represent the location of the big_data.csv file like so:
ste/
└── Downloads/
└── big_data.csv
To mark that ste and Downloads are folders, we add a final forward slash /. That simply means “hey! I am a folder!”. big_data.csv is a file, so it doesn’t have a final /. Instead, the file name big_data.csv has a file extension. The file extension is .csv. A file extension marks the type of file: in this the big_data file is a .csv file, a comma separated value file (we will see an example of what that looks like later). The name of the file is of course up to the user, but if you change the file extension you might have trouble later reading the file, so don’t change the file extension part yourself!
Different file types have different file extensions:
- Excel files:
.xlsx. - Plain text files:
.txt. - Images:
.png,.jpg,.gif. - Audio:
.mp3,.wav. - Video:
.mp4,.mov,.avi. - Etc…
A.1.1 File paths
Now, we can use an alternative, more succinct way, to represent the location of the big_data.csv:
ste/Downloads/big_data.csv
This is called a file path! It’s the path through folders that lead you to the file. Folders are separated by / and the file is marked with the extension .csv.
Now the million pound question: where does ste/ live on my computer??? User folders are located in different places depending on the operating system you are using:
On macOS: the user folder is in
/Users/.- You will notice that there is a forward slash also before the name of the folder. That is because the
/Users/folder is a top folder, i.e. there are no folders further up in the hierarchy of folders. - This means that the full path for the
big_data.csvfile on a computer running macOS would be:/Users/ste/Downloads/big_data.csv.
- You will notice that there is a forward slash also before the name of the folder. That is because the
On Windows: the user folder is in usually
C:/Users/, but the drive letter might not beC. We will useCfor convenience here.- You will notice that
Cis followed by a colon:. That is becauseCis a drive, which contains files and folders.C:is not contained by any other folder, i.e. there are no other folders aboveC:in the hierarchy of folders. - This means that the full path for the
big_data.csvfile on a Windows computer would be:C:/Users/ste/Downloads/big_data.csv.
- You will notice that
When a file path starts from a top-most folder, we call that path the absolute file path.
There is another type of file paths, called relative paths. A relative path is a partial file path, relative to a specific folder. You can learn how to use relative paths in Chapter 9. Importing files in R is very easy with the tidyverse packages. You just need to know the file type (very often the file extension helps) and the location of the file (i.e. the file path).