title: Passing string/ character argument when writing a function in R
body: <p>For example, I'm trying to write this function that converts a probability table into data.frame in R. I want the argument "na" to be the first colname of this data frame. </p>
  
  <pre><code>  prop_table_to_df &lt;- function(table, nm){
       data.frame(nm = factor(names(table)), Percentage = table)
    }
  </code></pre>
  
  <p>Suppose I call a function (sk_table, "age_group")
  The expected out output is this</p>
  
  <pre><code>        age_group Percentage
  (15,20]   (15,20]  0.4518717
  (20,25]   (20,25]  0.3118461
  (25,30]   (25,30]  0.2136201
  (30,35]   (30,35]  0.1863965
  </code></pre>
  
  <p>But instead the output is</p>
  
  <pre><code>             nm   Percentage
  (15,20]   (15,20]  0.4518717
  (20,25]   (20,25]  0.3118461
  (25,30]   (25,30]  0.2136201
  (30,35]   (30,35]  0.1863965
  </code></pre>
  
  <p>How do I fix this? Apparently, in this situation, R doesn't accept string or character as an argument when wrting the function. Thanks for helping. </p>