title: Create new variable based on other columns using R
body: <p>I have a huge file where I want to create a column based on other columns. 
  My file look like this:</p>
  
  <pre><code>person = c(1,2,3,4,5,6,7,8)
  father = c(0,0,1,1,4,5,5,7)
  mother = c(0,0,2,3,2,2,6,6)
  ped = data.frame(person,father,mother)
  </code></pre>
  
  <p>And I want to create a column indicating if the person is a father or mother (gender column). I got it using a for loop in a small example, but when I apply in the whole file it takes hours to finish. How can I create an apply function to solve that, please. Thanks. </p>
  
  <pre><code>for(i in 1:nrow(ped)){
    ped$test[i] = ifelse(ped[i,1] %in% ped[,2], "M", ifelse(ped[i,1] %in% ped[,3], "F", NA)) 
  }
  </code></pre>