Hi I am new to R so this might have a simple solution but I can't seem to work it out.
I am working with data from people who are in a relationship.
I have subset of my data with three variables familyID and var1female and var1male (with scores of 0 [never experienced behaviour] or 1 [has experienced behaviour) with over 9000 observations.
I would like to create a new categorical variable with 4 levels that shows if and who has engaged in the behavior that var1 depicts( 0= never experienced, 1= female only, 2=male only and 3= both female and male.
For example row one would be a 3 as both female and male have a score of 1.
This is what my data looks like (can't do it manually as I have over 9000 observations)
FAMID IPAsum_totalMd IPAsum_totalPd
<dbl> <dbl> <dbl>
1 10405 1 1
2 10426 0 0
3 10429 1 0
4 10431 0 1
5 10432 0 0
6 10433 1 1
I have been going over the examples online but haven't been able to find anything similar.
Any suggestions would be greatly appreciated!
Aucun commentaire:
Enregistrer un commentaire