Creating a new variable under conditions of other two variables

See FAQ: What's a reproducible example (`reprex`) and how do I do one?

If I understood your test correctly, that you want to create a new variable representing the highest score between the parents.

The | tests both parents for and returns 1 if any of the conditions are true

  1. Both parents are coded 1
  2. Father is coded 1
  3. Mother is coded 1

If none of these are satisfied, the new variable is coded 0, because neither both parents nor neither parent is coded 1.

1 Like