title: Dplyr standard evaluation using a vector of multiple strings with mutate function
body: <p>I am trying to supply a vector that contains multiple column names to a <code>mutate()</code> call using the <code>dplyr</code> package. Reproducible example below:</p>
  
  <pre><code>stackdf &lt;- data.frame(jack = c(1,NA,2,NA,3,NA,4,NA,5,NA),
                        jill = c(1,2,NA,3,4,NA,5,6,NA,7),
                        jane = c(1,2,3,4,5,6,NA,NA,NA,NA))
  two_names &lt;- c('jack','jill')
  one_name &lt;- c('jack')
  
  #   jack jill jane
  #    1    1    1
  #   NA    2    2
  #    2   NA    3
  #   NA    3    4
  #    3    4    5
  #   NA   NA    6
  #    4    5   NA
  #   NA    6   NA
  #    5   NA   NA
  #   NA    7   NA
  </code></pre>
  
  <p>I am able to figure out how to use the "one variable" versions, but do not know how to extend this to multiple variables? </p>
  
  <pre><code># the below works as expected, and is an example of the output I desire
  stackdf %&gt;% rowwise %&gt;% mutate(test = anyNA(c(jack,jill)))
  
  # A tibble: 10 x 4
      jack  jill  jane  test
     &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;lgl&gt;
   1     1     1     1 FALSE
   2    NA     2     2  TRUE
   3     2    NA     3  TRUE
   4    NA     3     4  TRUE
   5     3     4     5 FALSE
   6    NA    NA     6  TRUE
   7     4     5    NA FALSE
   8    NA     6    NA  TRUE
   9     5    NA    NA  TRUE
  10    NA     7    NA  TRUE
  
  
  # using the one_name variable works if I evaluate it and then convert to 
  # a name before unquoting it
  stackdf %&gt;% rowwise %&gt;% mutate(test = anyNA(!!as.name(eval(one_name))))
  
  # A tibble: 10 x 4
      jack  jill  jane  test
     &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt; &lt;lgl&gt;
   1     1     1     1 FALSE
   2    NA     2     2  TRUE
   3     2    NA     3 FALSE
   4    NA     3     4  TRUE
   5     3     4     5 FALSE
   6    NA    NA     6  TRUE
   7     4     5    NA FALSE
   8    NA     6    NA  TRUE
   9     5    NA    NA FALSE
  10    NA     7    NA  TRUE
  </code></pre>
  
  <p>How can I extend the above approach so that I could use the <code>two_names</code> vector? Using <code>as.name</code> only takes a single object so it does not work. </p>
  
  <p>This question here is similar: <a href="https://stackoverflow.com/questions/26497751/pass-a-vector-of-variable-names-to-arrange-in-dplyr">Pass a vector of variable names to arrange() in dplyr</a>. That solution "works" in that I can use the below code:</p>
  
  <pre><code>two_names2 &lt;- quos(c(jack, jill))
  stackdf %&gt;% rowwise %&gt;% mutate(test = anyNA(!!!two_names2))
  </code></pre>
  
  <p>But it defeats the purpose if I have to type <code>c(jack, jill)</code> directly rather than using the <code>two_names</code> variable. Is there some similar procedure where I can use <code>two_names</code> directly? This answer <a href="https://stackoverflow.com/questions/44656993/how-to-pass-a-named-vector-to-dplyrselect-using-quosures">How to pass a named vector to dplyr::select using quosures?</a> uses <code>rlang::syms</code> but though this works for selecting variables (ie <code>stackdf %&gt;% select(!!! rlang::syms(two_names))</code> it does not seem to work for supplying arguments when mutating (ie <code>stackdf %&gt;% rowwise %&gt;% mutate(test = anyNA(!!! rlang::syms(two_names)))</code>. This answer is similar but does not work: <a href="https://stackoverflow.com/questions/48053187/how-to-evaluate-a-constructed-string-with-non-standard-evaluation-using-dplyr?rq=1">How to evaluate a constructed string with non-standard evaluation using dplyr?</a></p>