Practice project: Clean Data (intermediate)

πŸ“˜ Scenario

You conducted a short survey with 6 statements. Three items measure everyday stress, and 3 items measure recovery behavior. Some items are negatively worded and need to be reverse-scored.
The scale ranges from 1 (strongly disagree) to 8 (strongly agree).

The items

🧠 Stress:

  1. I often feel rushed.
  2. I have too little time for myself.
  3. I cope well with stress. (reverse-scored)

🌿 Recovery:

  1. I consciously take breaks.
  2. I find it difficult to switch off. (reverse-scored)
  3. I regularly do things that are good for me.

Task

  1. Import the file stress_erholung.csv.
  2. Recode items 3 and 5 using the formula 9 - x (this mirrors 1 ↔ 8).
  3. Calculate the two scale means:
    • stress_score from items 1, 2, item3_rek
    • erholung_score from items 4, item5_rek, 6
      (Tip: Pay attention to missing values β€” they should be ignored!)
  4. Calculate a new variable differenz_score, that is, stress_score - erholung_score
    β†’ Positive values mean: more stress than recovery.
  5. Check whether the values look plausible.

πŸ’‘ Solution in R

I recorded a short video for you here.

Here is the solution as R code:

# 1. Import
data <- read.csv("stress_erholung.csv")

# 2. Recode the reverse-coded items
data$item3_rek <- 9 - data$item3
data$item5_rek <- 9 - data$item5

# 3. Calculate scale means (with NA handling)
data$stress_score <- rowMeans(data[, c("item1", "item2", "item3_rek")], na.rm = TRUE)
data$erholung_score <- rowMeans(data[, c("item4", "item5_rek", "item6")], na.rm = TRUE)

# 4. Calculate the difference variable
data$differenz_score <- data$stress_score - data$erholung_score

# 5. Check
head(data)

πŸ’‘ Solution in SPSS (step by step)

Here is the solution using the PSPP replica of SPSS.

1. Import

  • File β†’ Open Data β†’ Text File β†’ stress_erholung.csv
  • Delimiter: Comma β†’ Next β†’ Finish

2. Recode items 3 and 5 using 9 - x

  • Menu: Transform β†’ Compute Variable
  • New variable: item3_rek
    • Formula: 9 - item3
  • Repeat: item5_rek = 9 - item5

3. Calculate the scale means

  • Menu: Transform β†’ Compute Variable
  • New variable: stress_score
    • Formula: MEAN.3(item1, item2, item3_rek)
  • New variable: erholung_score
    • Formula: MEAN.3(item4, item5_rek, item6) (The .3 means: β€œat least 3 valid values are required”; you can also choose MEAN.2())

4. Calculate the difference

  • Transform β†’ Compute Variable
  • New variable: differenz_score
    • Formula: stress_score - erholung_score

5. Check the result

  • Data Editor β†’ display new variables
  • Menu: Analyze β†’ Descriptive Statistics β†’ Frequencies or Means