mardi 15 mai 2018

Simple if statement to recode variables

I am trying to use a simple if statement to separate a personal if number into a father id number and a mother id number (with NAs if the individual is of the wrong gender). Below is the code I am trying to use for the father number, but it is not working.

if (parent$gender==1){
 parent$fnr=parent$persnr
}else{
  parent$fnr=NA
  }

Aucun commentaire:

Enregistrer un commentaire