Week 4 - Installation of R and computer set-up
CHU0387 | National Taiwan Normal University
Overview
This week, we will have an introduction to the R language and the RStudio interface, which will be useful to analyze our data.
- Basics: What is R, and what is RStudio? How to download and install it?
- Getting ready: How to prepare your computer for future analyses?
A brief summary of the essential elements:
No code this week, just pay extra attention!
Please complete the following tasks before our next meeting:
- Make sure that your computer is ready for next week.
🎒 Part 1: Setup & Installation
So far, we have been talking about something called “R/RStudio”. People familiar with this program know what this is about. However, it can be quite confusing when we have never heard of it. We are actually referring to two distinct, yet connected programs:
The Engine: R

The main program where all the mathematical magic and deep computations happen.
The Dashboard: RStudio

A user-friendly interface that makes it incredibly easy to interact with R.
Maybe a metaphor can help to understand the difference between R and RStudio. As you are engaging yourself in this tutorial, I assume that you have a computer. You can create folders, open Word or Excel documents, write in them, and save them in the folders you created.
This is the exact same thing with R and RStudio. R will perform the computations that you ask for. And you will ask R to do stuff by clicking on icons and writing commands using the user-friendly interface of RStudio. And this is why you need to download two programs!
Step 1: Download and install R
Go to the RStudio website by clicking here. You will see something like this:

Next, choose your CRAN (The Comprehensive R Archive Network). Let’s choose the one in Taiwan. You will need to scroll down the page to find the link.

Choose the files to download according to your computer’s operating system. The most common are macOS (for Apple computers) or Windows.

On the next page, choose the subdirectory. For our purposes, we only need the “base” subdirectory.

We finally got to the last page! Click on the first link to download the files, as shown below. Wait until the file is downloaded, open it, and follow the standard instructions to install R on your computer.

Step 2: Download and install RStudio
Now that R is installed, it is time to do the same with RStudio. Go to the RStudio website by clicking here. You will see something like this:

Scroll down to look for the download links. Again, choose the right file for your operating system. Just click the link, let it download, open the file, and follow the instructions!

Look for the program called “RStudio” on your computer. Once you find it, just open it up, and you can move on to the next section!
Recall that R is the program where computations are done, and RStudio is the user-friendly interface. Even though we needed to download both, you actually only ever need to open RStudio when you want to use R! RStudio will talk to R in the background for you.
📊 Part 2: Prepare your computer: R projects
The most terrifying part when working with experimental data is that by the end of your study, you will have many files in your computer. It is very easy to be messy, to mix files from different steps, and even to have scripts and files for which we have no idea what they are. Therefore, we need to prepare our computer for each study beforehand.
- Please find you
Documents(or 文件) folder. - Once you found it, please create a folder for this class (you can call it
CHU0358_DocumentsScripts, for example) - Within this folder, please create subfolders, such as:
Slides: Where you can store the slides from this class,PreprocessingAnalysesR: Where you will store the datasets and scripts we are going to use in the rest of this class.
In the end, your folder will look like this:

Generally, it is better not to use any space when naming folders and files! R is also case sensitive, so pay attention to the capital and small letters!
There a small blue icon on the top-left side of RStudio. Please click on it.

Then, click on “Existing Directory”.

In the next window, click on “Browse…”, and look for the folder called
PreprocessingAnalysesRthat we just created. Please checkOpen in a new session, and on “Create Project”.
It will open a new and clean RStudio window. At the same time, it will set the PreprocessingAnalysesR as the working directory by default.
Another advantage is that you can have one RStudio window per project, and switch between them without worrying about the working directory of trying to find the right files! You can have a list of your several projects on the top-right corner of RStudio. Here is mine for example:
