Getting started

What you need

Install:

  1. R — the language and environment that performs the statistical computing;
  2. RStudio Desktop — the integrated development environment (IDE) used to write, run, inspect, and organize R work;
  3. Quarto — optional for students; needed only if you want to render the complete website or reproducible reports.

You do not need previous programming experience.

R and RStudio are not the same thing

R

  • programming language;
  • statistical computing environment;
  • runs calculations and models;
  • creates objects and graphics;
  • extended through packages.

RStudio

  • interface/IDE for working with R;
  • script editor;
  • Console;
  • Environment;
  • Files, Plots, Packages, Help.

A useful analogy is: R is the engine; RStudio is the dashboard and workspace.

Download the course

  1. Open the GitHub repository.
  2. Choose Code → Download ZIP.
  3. Extract the ZIP.
  4. Double-click r-for-management-research.Rproj.

Opening the .Rproj file gives the analysis a stable project context, so paths such as data/employee_survey.csv work on different computers.

Install the packages

Open R/install_packages.R and click Source, or run:

source("R/install_packages.R")

Check the setup:

source("R/check_setup.R")

Know the four panes

Pane Use
Source write and save scripts
Console execute commands immediately
Environment inspect objects currently stored in memory
Output Files, Plots, Packages, Help, Viewer

Script vs Console: experiment in the Console; keep meaningful analysis in a script. A script records what you did and makes the work reproducible.

Your first five minutes

2 + 2

course_name <- "Research & Evidence: Data, Methods & Design"
number_of_students <- 30

course_name
number_of_students

<- assigns a value to an object. Read it as “gets”.

After running those lines, look at the Environment pane. You should see the objects appear.

Run code

Place the cursor on a line and use:

  • Windows/Linux: Ctrl + Enter
  • macOS: Cmd + Enter

Run a script from top to bottom when later steps depend on objects created earlier.

File paths

Use project-relative paths:

employees <- readr::read_csv("data/employee_survey.csv")

Avoid machine-specific paths such as:

"C:/Users/YourName/Desktop/course/data.csv"

A simple debugging routine

When code fails:

  1. read the first error message;
  2. check spelling and capitalization;
  3. check commas, brackets, and quotation marks;
  4. confirm the package was loaded;
  5. confirm the object and variable names exist;
  6. rerun the earlier lines that create required objects.
Tip

Errors are normal. Treat them as information about the state of your analysis, not as a score of your programming ability.

Current references