title: Is it possible to add a third dummy variable using ifelse() in R?
body: <p>I was using this code to create a new Group column based on partial strings found inside the column var for 2 groups, <code>Sui</code> and <code>Swe</code>. I had to add another group, <code>TRD</code>, and I've been trying to tweak the <code>ifelse</code> function do this, but no success. Is this doable? are there any other solutions or other functions that might help me do this? </p>
  
  <pre><code>m.df &lt;- molten.df%&gt;% mutate(
  Group = ifelse(str_detect(variable, "Sui"), "Sui", "Swedish"))
  
  Current m.df: 
                            var      value    
    ADHD_iFullSuiTrim.Threshold1 0.00549427     
    ADHD_iFullSuiTrim.Threshold1 0.00513955     
    ADHD_iFullSweTrim.Threshold1 0.00466352   
    ADHD_iFullSweTrim.Threshold1 0.00491633   
    ADHD_iFullTRDTrim.Threshold1 0.00658535    
    ADHD_iFullTRDTrim.Threshold1 0.00609122    
  
  
  Desired Result:
                            var      value    Group
     ADHD_iFullSuiTrim.Threshold1 0.00549427    Sui  
     ADHD_iFullSuiTrim.Threshold1 0.00513955    Sui  
     ADHD_iFullSweTrim.Threshold1 0.00466352   Swedish
     ADHD_iFullSweTrim.Threshold1 0.00491633   Swedish
     ADHD_iFullTRDTrim.Threshold1 0.00658535    TRD
     ADHD_iFullTRDTrim.Threshold1 0.00609122    TRD  
  </code></pre>
  
  <p>Any help or suggestion would be appreciated even if the result can be accomplished using other functions. </p>