Basic computer literacy

Learn about basic computer terminology

Author

Stefano Coretta

Published

June 28, 2023

1 Some computer basics

In the tutorial last week you’ve been playing around with R, RStudio and R scripts.

But what if you want to import data in R?

Easy! You can use the read_*() functions (* is just a place holder for specific types of files to read, like read_csv() or read_excel()) to read your files into R. But before we dive in, let’s first talk about some computer basics. (You can skip this section if it’s too basic for you.)

Enable all extensions

Before moving on, we recommend you enable the option to show all file extensions in the File Explorer/Finder.

Follow the instructions here:

1.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.

User folder

The user folder is the folder with the name of your account.

On macOS

  • Go to Finder > Preferences/Settings.

  • Go to Sidebar.

  • The name next to the house icon is the name of your home folder.

On Windows

  • Right-click an empty area on the navigation panel in File Explorer.

  • From the context menu, select the ‘Show all folders’ and your user profile will be added as a location in the navigation bar.

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 type have different file extensions:

  • Excel files: .xlsx.
  • Plain text files: .txt.
  • Images: .png, .jpg, .gif.
  • Audio: .mp3, .wav.
  • Video: .mp4, .mov, .avi.
  • Etc…
File extension

A file extension is a sequence of letters that indicates the type of a file and it’s separated with a . from the file name.

1.2 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.

File path

A file path indicates the location of a file on a computer as a path through folders that lead you to the file.

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.csv file on a computer running macOS would be: /Users/ste/Downloads/big_data.csv.
  • On Windows: the user folder is in usually C:/Users/, but the drive letter might not be C. We will use C for convenience here.

    • You will notice that C is followed by a colon :. That is because C is a drive, which contains files and folders. C: is not contained by any other folder, i.e. there are no other folders above C: in the hierarchy of folders.
    • This means that the full path for the big_data.csv file on a Windows computer would be: C:/Users/ste/Downloads/big_data.csv.

When a file path starts from a top-most folder, we call that path the absolute file path.

Absolute path

An absolute path is a file path that starts with a top-most folder.

There is another type of file paths, called relative paths. A relative path is a partial file path, relative to a specific folder. You will learn how to use relative paths below, when we will go through importing files in R using R scripts below.

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).

The next sections will teach you how to import data in R!

Quiz 1
Which of the following is an absolute path?
Next