title: Using dollar sign vs brackets for use inside user-defined function?
body: <p>I've transitioned into writing some user-defined functions in R, but I'm hung up on whether it's best to use a dollar sign or bracket when indexing several data_frame columns.  My function is like this, for a conditional value replace:</p>
  
  <pre><code>replacer &lt;- function(df_col1,df_col2 i, k) {
    df_col1[df_col2 %in% i] &lt;-k
  }
  </code></pre>
  
  <p>Is there a better way to write this, one that has fewer arguments? With four arguments my way isn't very practical.</p>