Very green R user here. I have to categorical variables: One is, committee crime against child or has mental health issues (dichotomous, 1= crime and 0 = mental health) and committed crime against child or has substance abuse issues (dichotomous, 1= crime and 0 = substance abuse). I'd like to combine these groups so I will have a dichotomous, crime against child and mental health or substance abuse group. What would be the best way to do this? I have been playing around with "if" statements but to no avail.
I have been playing around with "if" statements but to no avail. I want to make a new variable in my dataset (com) that combines crime against child (1) and mental health/substance abuse (0)
x$com <- if(x$Group.finalCvsM == 1) {
x$com("1") }
if(x$Group.finalCvsS == 1) {
x$com("1") }
if(x$Group.finalCvsM == 0) {
x$com("0") }
if(x$Group.finalCvsS == 0) {
x$com("0") }
Aucun commentaire:
Enregistrer un commentaire