title: R: 'Missing Value where True/False needed'
body: <p>So I know this has been asked before, but from what I've searched I can't really find an answer to my problem. I should also add I'm relatively new to R (and any type of coding at all) so when it comes to fixing problems in code I'm not too sure what I'm looking for.</p>
  
  <p>My code is:</p>
  
  <pre><code>education_ge &lt;- data.frame(matrix(ncol=2, nrow=1))
  colnames(education_ge) &lt;- c("Education","Genetic.Engineering")
  
  for (i in 1:nrow(survey))
  if (survey[i,12]=="Bachelors")  
  education_ge$Education &lt;- survey[i,12]
  </code></pre>
  
  <p>To give more info, 'survey' is a data frame with 12 columns and 26 rows, and the 12th column, 'Education', is a factor which has levels such as 'Bachelors', 'Masters', 'Doctorate' etc.</p>
  
  <p>This is the error as it appears in R:</p>
  
  <pre><code>for (i in 1:nrow(survey))
    if (survey[i,12]=="Bachelors")  
      education_ge$Education &lt;- survey[i,12]
  Error in if (survey[i, 12] == "Bachelors") education_ge$Education &lt;- survey[i,  : 
    missing value where TRUE/FALSE needed
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>