CHU0387 | National Taiwan Normal University
Get to know R:
🎯 Objectives of this section
When you open RStudio for the very first time, you should see something similar to the picture below.

Click on the Files button in this block.
You will see a list of files and folders from your computer. This interface allows you to communicate and navigate directly with your hard drive, right from inside RStudio!
Take a second to play with it:
Click on the folders. Try to navigate to your Documents or Desktop. It works exactly like navigating folders on your computer normally does!
Environment tab: Where variables you create while coding are temporarily stored.
Nothing appears in the console, but look at the variable block:

a. You can call it anytime simply by typing a in the console, or even add to it by typing a + 2!
You just had a glimpse of it.
The console block is the engine room where the code is actually run.
When you type commands here and press Enter, R executes them immediately.
Your four blocks are like construction toys. You can change their size by dragging the borders, or even change the background color to a dark theme!
Path: Tools > Global Options... > Appearance > Editor theme
| Concept | Definition |
|---|---|
| Line of code | A single, simple instruction (e.g., 4 + 2). |
| Function | A pre-packaged cluster of code that performs a specific task. |
| Package / Library | A downloadable folder containing hundreds of useful functions! |
You only need to install a package once, but you must load it every time you open RStudio.
In your Console, type this to install ggplot2 (a famous plotting package):
The ‘cookbook metaphor’
Imagine you want to cook a complex dinner.
install.packages() is like going to the bookstore to buy a recipe book. You bring it home and put it on your shelf.
library() is like taking the book off the shelf and opening it on your kitchen counter. You have to open it every time you want to use those specific recipes!
Before doing anything, you must tell R which folder you are working in. This is your working directory.
Reminder!! Project set = Working directory set!
How to change it? Use the computer block to navigate to your project folder. Click the Gear Icon, and select “Save as Working Directory”.

Use the # symbol to write notes to yourself. R will completely ignore anything written after a hashtag!
Data to use
You need to download [this file] and place it in the folder for this class in the Documents folder of your computer.
Let’s import a .csv dataset (like an Excel file). We use the read.csv() function and assign it to a variable called data.
You can also use the RStudio interface. In the variable block: “Import Dataset” > “From Text (base)”, select your file, and click Import.

Once loaded, you can inspect your data using str(data) to see its structure, or summary(data) to get a quick mathematical overview.
Often, data comes in as plain text when it should be categorized into groups (Factors). We fix this using as.factor():
(The $ symbol tells R to look inside the dataset for a specific column!)
With our data summarized, we can use the built-in plot() function to visualize it:
📝 Assignment for next week
Please complete the following tasks before next Wednesday (10/14):