1. R, RStudio, and management data

Learning goals

After this lesson, you should be able to:

  • explain what R is and how RStudio differs from it;
  • explain why quantitative analysis matters in management research and practice;
  • recognize objects, functions, arguments, packages, scripts, data frames, variables, and observations;
  • import a CSV file and inspect its structure;
  • distinguish statistical variable types from R storage types;
  • explain why statistical reasoning remains necessary when using generative AI.

Management question: A company has an employee survey. Before calculating anything, what information is actually in the dataset, how is it represented, and what kinds of questions could it support?

Where quantitative analysis fits in management

Quantitative evidence is used in academic management research and in professional work:

People & organizations

Engagement, turnover, leadership, teams, performance.

Marketing

Experiments, segmentation, pricing, campaigns, customer behavior.

Strategy & operations

Forecasts, productivity, capacity, process performance, risk.

Finance & decision support

Performance, uncertainty, scenarios, resource allocation.

The basic logic is similar:

Question→Measurement→Data→Statistical model→Interpretation→Decision

What is R?

R is a programming language and environment for statistical computing and graphics. It is free, open-source, extensible through packages, and widely used for data analysis and research.

R is not a point-and-click application. We give it explicit instructions in code.

R versus RStudio

R performs the computing. RStudio organizes the work.

RStudio gives us a source editor, Console, Environment, file browser, plot pane, package manager, and help system.

The programming vocabulary you need first

Term Plain-language meaning Example
object a named thing stored in memory employees
function an action R can perform mean()
argument information supplied to a function na.rm = TRUE
package a collection of functions/data tidyverse
script a saved file of instructions 01-first-steps.R
data frame a rectangular dataset rows × columns
variable a column performance
observation a row one employee

Start with a tiny object

sales_k_eur <- 125
employees_count <- 40
sales_per_employee <- sales_k_eur / employees_count

sales_per_employee
[1] 3.125

After running the code, inspect the Environment pane.

Load a package

library() makes a package available in the current R session. The tidyverse provides tools for importing, transforming, and visualizing data.

Import the employee survey

employees <- read_csv(
  "data/employee_survey.csv",
  show_col_types = FALSE
)

Read this as:

  1. read_csv() reads the file;
  2. the result is assigned to employees;
  3. later commands can reuse that object.

Inspect before analysing

head(employees)
# A tibble: 6 × 26
  employee_id   age gender department remote_days tenure_years manager
  <chr>       <dbl> <chr>  <chr>            <dbl>        <dbl> <chr>  
1 E000001        37 Man    Operations           3          9.2 No     
2 E000002        32 Man    Operations           3          7   No     
3 E000003        22 Man    Operations           1          0.7 No     
4 E000004        44 Woman  Technology           1          4.2 No     
5 E000005        42 Woman  Operations           3          7.4 No     
6 E000006        41 Woman  Technology           0          1.6 Yes    
# ℹ 19 more variables: training_group <chr>, leadership_1 <dbl>,
#   leadership_2 <dbl>, leadership_3 <dbl>, leadership_4_reverse <dbl>,
#   engagement_1 <dbl>, engagement_2 <dbl>, engagement_3 <dbl>,
#   engagement_4_reverse <dbl>, role_clarity_1 <dbl>, role_clarity_2 <dbl>,
#   role_clarity_3 <dbl>, role_clarity_4 <dbl>, workload <dbl>,
#   organizational_support <dbl>, job_satisfaction <dbl>, performance <dbl>,
#   burnout <dbl>, turnover_intention <dbl>
glimpse(employees)
Rows: 480
Columns: 26
$ employee_id            <chr> "E000001", "E000002", "E000003", "E000004", "E0…
$ age                    <dbl> 37, 32, 22, 44, 42, 41, 48, 23, 32, 25, 51, 39,…
$ gender                 <chr> "Man", "Man", "Man", "Woman", "Woman", "Woman",…
$ department             <chr> "Operations", "Operations", "Operations", "Tech…
$ remote_days            <dbl> 3, 3, 1, 1, 3, 0, 3, 0, 3, 4, 2, 0, 4, 1, 2, 2,…
$ tenure_years           <dbl> 9.2, 7.0, 0.7, 4.2, 7.4, 1.6, 1.6, 2.9, 10.0, 6…
$ manager                <chr> "No", "No", "No", "No", "No", "Yes", "No", "Yes…
$ training_group         <chr> "Training", "Training", "Control", "Training", …
$ leadership_1           <dbl> 1, 3, 5, 3, 3, 2, 3, 3, 5, 2, 4, 5, 1, 2, 1, 2,…
$ leadership_2           <dbl> 1, 1, 5, 2, 4, 3, 3, 4, 5, 1, 5, 5, 1, 1, 1, 2,…
$ leadership_3           <dbl> 1, 1, 5, 3, 5, 4, 4, 2, 5, 2, 5, 5, 1, 1, 2, 2,…
$ leadership_4_reverse   <dbl> 5, 5, 1, 4, 1, 3, 3, 4, 1, 5, 2, 1, 3, 4, 4, 3,…
$ engagement_1           <dbl> 2, 3, 5, 4, 5, 3, 5, 2, 5, 3, 4, 5, 3, 2, 4, 5,…
$ engagement_2           <dbl> 2, 1, 3, 5, 4, 4, 5, 1, 5, 2, 4, 5, 4, 2, 3, 1,…
$ engagement_3           <dbl> 1, 1, 4, 4, 4, 4, 5, 2, 5, 2, 5, 5, 4, 1, 3, 3,…
$ engagement_4_reverse   <dbl> 3, 4, 1, 2, 2, 4, 1, 3, 1, 5, 1, 1, 3, 5, 2, 2,…
$ role_clarity_1         <dbl> 1, 1, 4, 4, 5, 4, 3, 2, 3, 3, 5, 3, 2, 1, 1, 2,…
$ role_clarity_2         <dbl> 1, 3, 3, 5, 4, 4, 5, 3, 4, 2, 5, 5, 1, 1, 1, 1,…
$ role_clarity_3         <dbl> 1, 2, 3, 4, 4, 3, 4, 3, 5, 4, 5, 2, 2, 1, 1, 2,…
$ role_clarity_4         <dbl> 1, 4, 3, 3, 3, 2, 5, 5, 5, 3, 4, 4, 2, 1, 1, 3,…
$ workload               <dbl> 3.44, 4.68, 4.68, 4.09, 4.26, 2.25, 2.79, 4.16,…
$ organizational_support <dbl> 2.50, 3.92, 5.09, 3.72, 3.63, 3.97, 5.58, 4.25,…
$ job_satisfaction       <dbl> 2.52, 4.17, NA, 4.87, 3.17, 5.68, 4.86, 3.77, 5…
$ performance            <dbl> 45.1, 43.8, 52.2, 60.3, 59.9, NA, 64.3, 48.1, 6…
$ burnout                <dbl> 49.8, 48.5, 47.4, 47.1, 51.8, 36.3, 32.1, 46.6,…
$ turnover_intention     <dbl> 4.84, 4.18, 3.66, 4.12, 4.62, 2.83, 3.16, 5.26,…
names(employees)
 [1] "employee_id"            "age"                    "gender"                
 [4] "department"             "remote_days"            "tenure_years"          
 [7] "manager"                "training_group"         "leadership_1"          
[10] "leadership_2"           "leadership_3"           "leadership_4_reverse"  
[13] "engagement_1"           "engagement_2"           "engagement_3"          
[16] "engagement_4_reverse"   "role_clarity_1"         "role_clarity_2"        
[19] "role_clarity_3"         "role_clarity_4"         "workload"              
[22] "organizational_support" "job_satisfaction"       "performance"           
[25] "burnout"                "turnover_intention"    
dim(employees)
[1] 480  26

In RStudio, try:

View(employees)

The spreadsheet-like viewer is useful for orientation, but your actual analysis should remain in code.

Statistical type versus R type

These are related but not identical.

Statistical meaning

  • nominal categorical: department, country, treatment group;
  • ordinal categorical: satisfaction category, rating;
  • discrete numeric: number of employees;
  • continuous numeric: sales, age, performance.

Common R storage classes

R display Meaning
chr character/text
dbl numeric double
int integer
lgl TRUE/FALSE
fct factor/category
Date calendar date

A variable coded as 1, 2, 3 is not automatically a continuous quantity. You need to understand what those numbers mean before choosing an analysis.

Script versus Console

Console

  • immediate;
  • useful for trying a command;
  • easy to lose;
  • poor record of a full analysis.

Script

  • saved;
  • editable;
  • rerunnable;
  • shareable;
  • basis of reproducible analysis.

Course habit: experiment in the Console; keep meaningful work in the script.

Why learn this when GenAI can write R?

AI can help:

  • explain code;
  • draft syntax;
  • debug;
  • suggest a plot or function.

But you still decide whether:

  • the data measure the intended concept;
  • the test matches the design;
  • assumptions are reasonable;
  • the direction of a hypothesis was defined in advance;
  • repeated/nested observations require a different model;
  • the output supports a descriptive, associational, predictive, or causal claim.

AI can generate code. It cannot make an invalid research design valid.

Practice

  1. Open code/01-first-steps.R.
  2. Run it one block at a time.
  3. Find the number of rows and columns.
  4. Select performance with employees$performance.
  5. Ask R for help with ?summary.
  6. In one sentence, describe one research question this dataset could support.

Takeaway

The first step in R is not a statistical test. It is understanding the question, data structure, variable meaning, and analysis environment.

References