Introduction to RStudio

Day 1 - Introduction to Data Analysis with R

Selina Baldauf

Freie Universität Berlin - Theoretical Ecology

March 6, 2026

Difference between R and RStudio

Analogy and image from ModernDive Book

R is the programming language and the program that does the actual work

RStudio is the integrated development environment (IDE).

Interface to R, syntax highlighting, file management, …

A quick tour around RStudio

A quick tour around RStudio

Console pane

  • Execute R code

  • Output from R code in scripts is printed there

  • Type a command into the console and execute with Enter/Return

Tip

Use arrow keys to bring back last commands

Script pane

  • Write scripts with R code

    • Scripts are text files with R commands (file ending .R)

    • Use scripts to save commands for reuse

Script pane

  • Create a new R script:
    File -> New File -> R Script
  • Save an R script:
    File->Save (Ctrl/Cmd + S)
  • Run code line by line with Run button (Ctrl+Enter/Cmd+Return)
  • You can open multiple scripts

Script vs Console

Use scripts for all your analysis and for commands that you want to save.
Use console for temporary commands, e.g. to test something.

Environment pane

  • Shows objects currently present in the R session

  • Is empty if you start R

Files pane

  • Similar to Explorer/Finder

  • Browse project structure and files

    • Find and open files
    • Create new folders
    • Delete and rename files

Plot pane

  • Plots that are created with R will be shown here

A tip before we get started

Learn the most important keyboard shortcuts of RStudio.

Find all shortcuts under Tools -> Keyboard Shortcuts Help

  • Save active file: Ctrl/Cmd + S
  • Run current line: Ctrl/Cmd + Enter
  • Create new R Script: Ctrl/Cmd + N
  • Undo: Ctrl/Cmd + Z
  • Redo: Ctrl/Cmd + Y
  • Copy/Paste: Ctrl/Cmd + C/V

RStudio projects

Idea: One directory (folder) with all files relevant for project (data, R scripts, figures, …)

  • An RStudio project is just a normal folder with an .Rproj file
  • Helps R to find your project files
MyProject
|
|- data
|
|- R
|   |
|   |- clean_data.R 
|   |
|   |- statistics.R
|
|- figures
|
|- MyProject.RProj

Example RStudio project structure

Create an RStudio project

Create a project from scratch:

  1. File -> New Project -> New Directory -> New Project
  2. Enter a directory name (this will be the name of your project)
  3. Choose the Directory where the project should be initiated
  4. Create Project

Example RStudio project structure in the Files pane

RStudio will now create and open the project for you.

Open an RStudio project

From file explorer/finder:
Double click on the .Rproj file

From inside RStudio:
Click the project symbol on the top right

Now you

Task 1 (15 min)

Set up your own RStudio project for this workshop

Find the task description here