title: How to pass column names in function to carry out filter, select and sort actions within a function in R
body: <p>I am trying to carry out the filter, select and arrange actions on a data frame by defining the function.</p>
  <p>Below is the code i am trying to replicate by a function:</p>
  <pre><code>mtcars %&gt;%  
    filter(disp &gt; 150) %&gt;%  
    select(disp, hp) %&gt;%  
    arrange(hp)
  </code></pre>
  <p>The function i have created is as below:</p>
  <pre><code>process_data &lt;- function(df, col_1, col_2){
    df %&gt;%  filter(col_1 &gt; 150) %&gt;%  
      select(col_1, col_2)
  }
  
  process_data(df = mpg, col_1 = &quot;disp&quot;, col_2 = &quot;hp&quot;)
  </code></pre>
  <p>However when i try to execute the i get the below error:</p>
  <p>Error: Can't subset columns that don't exist.
  x Column <code>disp</code> doesn't exist.</p>
  <p>Tried multiple ways of passing the column name, but it isnt working.</p>