title: How can I use case_when inside dplyr mutate() function?
body: <p>As far as I understand, <code>case_when()</code> is a generalised version of <code>ifelse()</code>. </p>
  
  <p>However, I don't understand how to use this function inside <code>dplyr::mutate()</code> function. It used to work using github's last version of dplyr but since I'm back to the CRAN version (0.5), it doesn't work anymore. Does anyone has a clue ? </p>
  
  <p>Here is my reproducible example : </p>
  
  <p>
  <br/></p>
  
  <pre class="lang-r prettyprint-override"><code>library(devtools)
  library(tibble)
  library(dplyr)
  #&gt; 
  #&gt; Attaching package: 'dplyr'
  #&gt; The following objects are masked from 'package:stats':
  #&gt; 
  #&gt;     filter, lag
  #&gt; The following objects are masked from 'package:base':
  #&gt; 
  #&gt;     intersect, setdiff, setequal, union
  
  tibble(
    group = c("A", "A", "A", "B", "B", "B"), 
    x = 1:6
    ) %&gt;% 
    mutate(
      y = ifelse(group == "A", -x, x)
      )
  #&gt; # A tibble: 6 × 3
  #&gt;   group     x     y
  #&gt;   &lt;chr&gt; &lt;int&gt; &lt;int&gt;
  #&gt; 1     A     1    -1
  #&gt; 2     A     2    -2
  #&gt; 3     A     3    -3
  #&gt; 4     B     4     4
  #&gt; 5     B     5     5
  #&gt; 6     B     6     6
  
  tibble(
    group = c("A", "A", "A", "B", "B", "B"), 
    x = 1:6
    ) %&gt;% 
    mutate(
      y = case_when(
        group == "A" ~ -x, 
        TRUE ~ x
        )
    )
  #&gt; Error in mutate_impl(.data, dots): object 'group' not found
  
  tibble(
    group = c("A", "A", "A", "B", "B", "B"), 
    x = 1:6
    ) %&gt;%
    mutate_(
      .dots = list(
        "y" = lazyeval::interp( 
          ~ case_when(var1 == "A" ~ -var2, TRUE, var2), 
          var1 = as.name(group), 
          var2 = as.name(x)
          )
      )
    )
  #&gt; Error in as.name(group): object 'group' not found
  
  
  
  devtools::session_info()
  #&gt; Session info -------------------------------------------------------------
  #&gt;  setting  value                       
  #&gt;  version  R version 3.3.2 (2016-10-31)
  #&gt;  system   x86_64, linux-gnu           
  #&gt;  ui       X11                         
  #&gt;  language (EN)                        
  #&gt;  collate  C                           
  #&gt;  tz       &lt;NA&gt;                        
  #&gt;  date     2017-03-10
  #&gt; Packages -----------------------------------------------------------------
  #&gt;  package    * version     date       source                            
  #&gt;  assertthat   0.1         2013-12-06 CRAN (R 3.2.2)                    
  #&gt;  backports    1.0.5       2017-01-18 cran (@1.0.5)                     
  #&gt;  DBI          0.6         2017-03-09 cran (@0.6)                       
  #&gt;  devtools   * 1.12.0.9000 2017-03-07 Github (hadley/devtools@d8ab190)  
  #&gt;  digest       0.6.12      2017-01-27 cran (@0.6.12)                    
  #&gt;  dplyr      * 0.5.0       2016-06-24 CRAN (R 3.3.2)                    
  #&gt;  evaluate     0.10        2016-10-11 cran (@0.10)                      
  #&gt;  htmltools    0.3.5       2016-03-21 CRAN (R 3.2.3)                    
  #&gt;  knitr        1.15.1      2016-11-22 cran (@1.15.1)                    
  #&gt;  lazyeval     0.2.0.9000  2016-10-14 Github (hadley/lazyeval@c155c3d)  
  #&gt;  magrittr     1.5         2014-11-22 CRAN (R 3.2.3)                    
  #&gt;  memoise      1.0.0.9001  2017-02-13 Github (hadley/memoise@884d565)   
  #&gt;  pkgbuild     0.0.0.9000  2017-03-07 Github (r-pkgs/pkgbuild@65eace0)  
  #&gt;  pkgload      0.0.0.9000  2017-03-07 Github (r-pkgs/pkgload@fc907a1)   
  #&gt;  R6           2.2.0       2016-10-05 cran (@2.2.0)                     
  #&gt;  Rcpp         0.12.9      2017-01-14 cran (@0.12.9)                    
  #&gt;  rmarkdown    1.3.9004    2017-03-09 Github (rstudio/rmarkdown@01dc037)
  #&gt;  rprojroot    1.2         2017-01-16 cran (@1.2)                       
  #&gt;  stringi      1.1.2       2016-10-01 CRAN (R 3.3.1)                    
  #&gt;  stringr      1.2.0       2017-02-18 cran (@1.2.0)                     
  #&gt;  tibble     * 1.2         2016-08-26 CRAN (R 3.2.3)                    
  #&gt;  withr        1.0.2       2016-06-20 CRAN (R 3.2.3)                    
  #&gt;  yaml         2.1.14      2016-11-12 cran (@2.1.14)
  </code></pre>