title: Creating a new column from an existing column using R
body: <p>I am trying to create a new column (variable) according to the values that appear in an existing column such that if there is an NA in the existing column then the corresponding value in the new column should be 0 (zero), if not NA then it should be 1 (one). An example data is given below:</p>
  
  <pre><code>aid=c(1,2,3,4,5,6,7,8,9,10)
  age=c(2,14,NA,0,NA,1,6,9,NA,15)
  data=data.frame(aid,age)
  </code></pre>
  
  <p>My new data frame should look like this:</p>
  
  <pre><code>aid=c(1,2,3,4,5,6,7,8,9,10)
  age=c(2,14,NA,0,NA,1,6,9,NA,15)
  surv=c(1,1,0,1,0,1,1,1,0,1)
  data&lt;-data.frame(aid,age,surv)
  data
  </code></pre>
  
  <p>I hope that my question is clear enough.</p>
  
  <p>The R community's help is highly appreciated!</p>
  
  <p>Baz</p>