Exercise

# Calculate correlations

It is also interesting to look at the correlations by group.

A moderator predicts that the correlation between the predictor and the outcome will change in function of the group. So if a clear change is observed in the correlations as a function of group, then this can indicate a significant moderation effect.

In this exercise, you have to calculate the **correlations** between the IQ scores `iq`

and the working memory capacity `wm`

**by group**.

Instructions

**100 XP**

- You first need to create subsets of the
`mod`

dataframe for each group, using`subset()`

. Assign to`mod_control`

,`mod_threat1`

and`mod_threat2`

the subsets of`mod`

for respectively the conditions: "control", "threat1" and "threat2". - Calculate the
**correlations**between`iq`

and`wm`

for each of the above subsets respectively, with the function`cor()`

, and print the results to the console.