title: Dplyr across + mutate + condition to select the columns
body: <p>I am sure the solution is a one liner, but I am banging my head against the wall.
  See the very short reprex at the end of the post; how do I tell dplyr that I want to double only the columns without NA?</p>
  <p>Many thanks</p>
  <pre class="lang-r prettyprint-override"><code>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
  
  
  df &lt;- tibble(x=1:10, y=101:110,
               w=c(6,NA,4,NA, 5,0,NA,4,8,17 ),
               z=c(2,3,4,NA, 5,10,22,34,58,7 ),
               k=rep(&quot;A&quot;,10))
  
  
  df
  #&gt; # A tibble: 10 x 5
  #&gt;        x     y     w     z k    
  #&gt;    &lt;int&gt; &lt;int&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt;
  #&gt;  1     1   101     6     2 A    
  #&gt;  2     2   102    NA     3 A    
  #&gt;  3     3   103     4     4 A    
  #&gt;  4     4   104    NA    NA A    
  #&gt;  5     5   105     5     5 A    
  #&gt;  6     6   106     0    10 A    
  #&gt;  7     7   107    NA    22 A    
  #&gt;  8     8   108     4    34 A    
  #&gt;  9     9   109     8    58 A    
  #&gt; 10    10   110    17     7 A
  
  
  df %&gt;% mutate(across(where(is.numeric), ~.x*2))
  #&gt; # A tibble: 10 x 5
  #&gt;        x     y     w     z k    
  #&gt;    &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;chr&gt;
  #&gt;  1     2   202    12     4 A    
  #&gt;  2     4   204    NA     6 A    
  #&gt;  3     6   206     8     8 A    
  #&gt;  4     8   208    NA    NA A    
  #&gt;  5    10   210    10    10 A    
  #&gt;  6    12   212     0    20 A    
  #&gt;  7    14   214    NA    44 A    
  #&gt;  8    16   216     8    68 A    
  #&gt;  9    18   218    16   116 A    
  #&gt; 10    20   220    34    14 A
  
  
  ##now double the value of all the columns without NA. How to fix this...
  
  df %&gt;% mutate(across(where(sum(is.na(.x))==0), ~.x*2))
  #&gt; Error: Problem with `mutate()` input `..1`.
  #&gt; ✖ object '.x' not found
  #&gt; ℹ Input `..1` is `across(where(sum(is.na(.x)) == 0), ~.x * 2)`.
  </code></pre>
  <p><sup>Created on 2020-10-27 by the <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex package</a> (v0.3.0.9001)</sup></p>