title: Best tidyverse practice for passing column names as variables in function
body: <p>I am passing a tibble to a user-defined function where column names are variables. After studying <a href="https://stackoverflow.com/questions/67725704/how-to-refer-to-a-variable-inside-a-function-with-tidy-eval-after-renaming-it">this</a>, <a href="https://stackoverflow.com/questions/48219732/pass-a-string-as-variable-name-in-dplyrfilter">this</a>, and <a href="https://stackoverflow.com/questions/27197617/filter-data-frame-by-character-column-name-in-dplyr">this</a>, I came up with the below working function. My goal is to include an equivalent function in an R package. My question, while this function works, is there a more correct best practice within the dplyr/tidyeval/tidyverse world?</p>
  <pre><code>library(tidyverse)
  
  dat0 &lt;- tibble( a = seq(as.Date('2022-02-10'), as.Date('2022-03-01'), by = &quot;5 days&quot;)
    , b = seq(10,40,10))
  
  myCalc &lt;- function(data, dateIn, numIn, yearOut, numOut) {
    data &lt;- data %&gt;%
      mutate(.
        , {{yearOut}} := lubridate::year(.data[[dateIn]])
        , {{numOut}} := 10 * .data[[numIn]]
        ) %&gt;%
      filter(.
        , .data[[numOut]] &gt; 250
        )
  }
  
  dat2 &lt;- myCalc(dat0
    , dateIn  = &quot;a&quot;
    , numIn   = &quot;b&quot;
    , yearOut = &quot;c&quot;
    , numOut  = &quot;d&quot;)
  
  dat2
  
      # A tibble: 2 × 4
    a              b     c     d
    &lt;date&gt;     &lt;dbl&gt; &lt;dbl&gt; &lt;dbl&gt;
  1 2022-02-20    30  2022   300
  2 2022-02-25    40  2022   400
  </code></pre>