title: Replace column values with column name using dplyr's transmute_all
body: <p>Data set contains many columns containing values which are either NA or 1, kind of like this:</p>
  
  <pre><code>&gt; data_frame(a = c(NA, 1, NA, 1, 1), b=c(1, NA, 1, 1, NA))
  # A tibble: 5 x 2
        a     b
    &lt;dbl&gt; &lt;dbl&gt;
  1 NA     1.00
  2  1.00 NA   
  3 NA     1.00
  4  1.00  1.00
  5  1.00 NA  
  </code></pre>
  
  <p>Desired output: replace all the 1 values with the name of the column as a string,</p>
  
  <pre><code>&gt; data_frame(a = c(NA, 'a', NA, 'a', 'a'), b=c('b', NA, 'b', 'b', NA))
  # A tibble: 5 x 2
    a     b    
    &lt;chr&gt; &lt;chr&gt;
  1 &lt;NA&gt;  b    
  2 a     &lt;NA&gt; 
  3 &lt;NA&gt;  b    
  4 a     b    
  5 a     &lt;NA&gt; 
  </code></pre>
  
  <p>here's my attempt using an anonymous function in transmute_all:</p>
  
  <pre><code>&gt; data_frame(a = c(NA, 1, NA, 1, 1), b=c(1, NA, 1, 1, NA)) %&gt;%
  +     transmute_all(
  +         funs(function(x){if (x == 1) deparse(substitute(x)) else NA})
  +     )
  Error in mutate_impl(.data, dots) : 
    Column `a` is of unsupported type function
  </code></pre>
  
  <p>EDIT: Attempt # 2:</p>
  
  <pre><code>&gt; data_frame(a = c(NA, 1, NA, 1, 1), b=c(1, NA, 1, 1, NA)) %&gt;%
  +     transmute_all(
  +         funs(
  +             ((function(x){if (!is.na(x)) deparse(substitute(x)) else NA})(.))
  +             )
  +     )
  # A tibble: 5 x 2
    a     b    
    &lt;lgl&gt; &lt;chr&gt;
  1 NA    b    
  2 NA    b    
  3 NA    b    
  4 NA    b    
  5 NA    b    
  Warning messages:
  1: In if (!is.na(x)) deparse(substitute(x)) else NA :
    the condition has length &gt; 1 and only the first element will be used
  2: In if (!is.na(x)) deparse(substitute(x)) else NA :
    the condition has length &gt; 1 and only the first element will be used
  &gt; 
  </code></pre>