3.1 Computer Basics

If you’re new to computers, this section will be important for you to get set up. We’ll briefly introduce some computer concepts and discuss how they’re relevant to R. If you understand the basics of operating systems, directory structures on your computer, and downloading/installing files, then you can probably skim this section, but be sure to pay attention to the R-specific information.

3.1.1 Operating Systems

An operating system is a set of programs that allow you to interact with the computer, and the most popular operating systems are Windows, macOS, and Linux. R works on Windows, macOS, and several Linux-based operating systems, so if you have one of these operating systems, you’ll be able install and use R. At least, this is mostly true:

Some versions of Windows that run on ARM processors cannot install R, and installing R on a Chromebook will likely be more complicated (see here). If you’re in this situation, contact the instructor immediately.

R isn’t designed to work on tablets or phones which run mobile/tablet operating systems (like iOS, iPadOS, Android, ChromeOS), so these are not an option for R.

3.1.2 Files & Directory Structures

A file is a collection of data stored on your computer’s hard drive. Examples of files include:

  • A music file
  • A video
  • A slide presentation
  • A text document

Different types of files are often treated differently by your computer. For example, a music file is played with a music player program, a video can be viewed with a video player, and a slide presentation might be viewed with Powerpoint. Most operating systems know the type of a file by looking at the extension, which is at the very end of the file’s name. Examples include “.mp3”, “.doc”, “.txt”, and “.ppt”. When using R, we can write scripts which contain R code, and R Markdown documents, which include human readable text and code. R scripts usually have either a “.R” or “.r” extension, and we’ll also be using R Markdown, which use either a “.Rmd” or “.rmd” extension.

A directory, or folder, is a collection of files, and computers use directories to logically organize sets of files. When working with R, you may have to organize several different types of files, including R code, data files, and images. It will be important to stay organized when using R, and we will address this more later in the chapter.

With the increasing prevalence of the internet in everyday life, it’s becoming less common for files to exist on your computer. When writing R code, you’ll be working with files on your computer, not accessing them over the internet.

3.1.3 Downloads and Installations

To install R, you’ll have to download a file from the internet which performs the installation. After you install R, you shouldn’t have to download anything to run R. The specific steps to install R will be different depending on your operating system, and this will be addressed in the next section.