This exercise is designed to reinforce the basic operations of importing data, recoding items, and calculating scale means.
📘 Task description
Imagine you want to find out how fond of animals different people are. You conducted a small survey in which participants answered 5 statements—each on a scale from 1 (not at all) to 5 (completely). Your task is to calculate an animal-fondness score from these items. (Bonus question: You can consider whether the items listed actually capture the construct being investigated—animal fondness; you can find information on this, for example, here).
Here are the items:
- I think cats are cute.
- I am afraid of spiders. (reverse-coded)
- I like talking to dogs.
- I enjoy watching birds.
- I avoid animals whenever possible. (reverse-coded)
All questions are rated on what is known as a Likert scale. “1” means “I disagree,” while “5” means “I strongly agree.”
🧪 Tasks:
- Import the file
tierliebe.csvinto R or SPSS. - Recode the two negatively worded items using the formula
6 - x.
(This applies to Items 2 and 5; in SPSS, you can of course also use the “Recode” function.) - Calculate the mean of all 5 items for each person and save it in a new variable
tierliebe_score. - Take a look at the dataset: Did everything work? To test it, do it in R and SPSS and simply compare the results.
💡 Solution in R
I recorded a video (quick & dirty) showing the solution here.
Here is the clean, written solution as R code.
# 1. Daten importieren
daten <- read.csv("tierliebe.csv")
# 2. Rekodieren (6 - x) für Item 2 und 5
daten$item2_rek <- 6 - daten$item2
daten$item5_rek <- 6 - daten$item5
# 3. Skalenwert berechnen mit rowMeans
daten$tierliebe_score <- rowMeans(daten[, c("item1", "item2_rek", "item3", "item4", "item5_rek")])
# 4. Kontrolle
head(daten)
💡 Solution in SPSS
- Import the data:
- Open SPSS
- Go to File → Open Data → Text File…
- Select
tierliebe.csv - Click through the wizard (commas as delimiters)
- Reverse-score items 2 and 5 using “6 – x”:
- Go to Transform → Compute Variable (Alternatively, you can of course use the recoding function directly!)
- Enter a new variable name, e.g.
item2_rek - Formula:
6 - item2 - Repeat this for
item5_rekusing6 - item5
- Calculate the mean:
- Transform → Compute Variable
- New variable:
tierliebe_score - Function:
MEAN(item1, item2_rek, item3, item4, item5_rek)
- View the result:
- Click View Data
- Check whether the new column
tierliebe_scorecontains values
Documenting the Results
When learning statistics, it is not only important to be able to execute the commands correctly (even though this is what causes most problems at the beginning, simply because it is so new). More important, however, is understanding the individual steps as well. So here is a short quiz designed to help you reflect once again on individual operations from the exercise (and slightly beyond).
Alles klar?
Ich hoffe, der Beitrag war für dich soweit verständlich. Wenn du weitere Fragen hast, nutze bitte hier die Möglichkeit, eine Frage an mich zu stellen!
