title: create subgroups as new variable
body: <p>Is there a convinient way to generate new variables that contain subtypes. (for analysis)</p>
  
  <p>E.g. we have <code>smoker</code> status, <code>sex</code> and <code>lifeQuality</code>.</p>
  
  <p>Lets say we want to test smoker-female vs non-smoker-female in respect to <code>lifeQuality</code></p>
  
  <p>Is there a convinient and !general way! to get my desired subgroups (<code>femaleSmoker</code> and <code>maleSmoker</code>)?</p>
  
  <pre><code>set.seed(1337)
  df &lt;- data.frame(smoker=sample(c("yes","no"),10,replace = T),sex=sample(c("male","female"),10,replace = T),lifeQuality=rnorm(10))
  
  df$femaleSmoker &lt;- paste0(df$sex,"_",df$smoker)
  df$femaleSmoker[df$sex=="male"] &lt;- NA
  
  df$maleSmoker &lt;- paste0(df$sex,"_",df$smoker)
  df$maleSmoker[df$sex=="female"] &lt;- NA
  
  &gt; df
     smoker    sex lifeQuality femaleSmoker maleSmoker
  1      no   male   1.0467758         &lt;NA&gt;    male_no
  2     yes female   0.7706077   female_yes       &lt;NA&gt;
  3     yes   male   0.3980541         &lt;NA&gt;   male_yes
  4      no female  -0.3171052    female_no       &lt;NA&gt;
  5      no female  -1.3180397    female_no       &lt;NA&gt;
  6     yes   male   1.0174820         &lt;NA&gt;   male_yes
  7      no   male  -1.6237908         &lt;NA&gt;    male_no
  8     yes   male  -0.5703763         &lt;NA&gt;   male_yes
  9     yes   male   0.3104756         &lt;NA&gt;   male_yes
  10     no   male  -2.6101319         &lt;NA&gt;    male_no
  &gt; 
  </code></pre>