title: Creating a new variable under conditions of other two variables
body: <p>I'm trying to create a new variable in a dataset under some conditions of other variables. Basically, I want to simplify the information about education of parents, that is split between father and mother, and create a new one, that takes in account the highest level of education of the parents. For example, if the father education level is 1 and mother education is 0, the value for this row in the new variable would be 1.</p>
  
  <p>I'm trying to use <code>mutate()</code> with <code>case_when()</code> functions, that worked in another variable, but I'm not understanding why isn't right now. When I try, it creates a column with only NA's and when I print a table from it, the result is:</p>
  
  <blockquote>
    <p>&lt; table of extent 0 ></p>
  </blockquote>
  
  <p>The class of the two variables that I'm using for conditions is 'labelled' and 'factor'.</p>
  
  <p>First, I tried the following command (I'm simplifying the codes):</p>
  
  <pre><code>dataset &lt;- dataset %&gt;% 
             mutate(NEW_EDUCATIONAL_VAR = case_when(MOTHER_EDUCATIONAL_VAR == '0' &amp;  FATHER_EDUCATIONAL_VAR == '0' ~ '0',
                                                    MOTHER_EDUCATIONAL_VAR == '0' &amp; FATHER_EDUCATIONAL_VAR == '1' ~ '1')
  </code></pre>
  
  <p>Then, I tried to consider the cases that has NA values, since there is NA in some rows:</p>
  
  <pre><code>dataset &lt;- dataset %&gt;% 
             mutate(NEW_EDUCATIONAL_VAR = case_when(is.na(MOTHER_EDUCATIONAL_VAR) &amp; is.na(FATHER_EDUCATIONAL_VAR) ~ '99',
                                                    MOTHER_EDUCATIONAL_VAR == '0' &amp; FATHER_EDUCATIONAL_VAR == '1' ~ '1')
  </code></pre>
  
  <p>When I used these functions for create a new one for the age of the cases, it worked. </p>
  
  <pre><code>dataset &lt;- dataset %&gt;% mutate(AGE_CAT = case_when(AGE &gt;= 16 &amp; AGE &lt;= 18 ~ '0',
                                                     AGE &gt;= 19 &amp; AGE &lt;= 24 ~ '1',
                                                     AGE &gt;= 25 &amp; AGE &lt;= 29 ~ '2',
                                                     AGE &gt;= 30 ~ '3'))
  </code></pre>
  
  <p>So, what am I doing wrong? Thanks a lot.</p>