title: Dynamically select column from data frame in function
body: <p>I have a data frame from which I want to select a column. For that purpose I have defined a function. The name of the column is provided as parameter:</p>
  
  <pre><code>d &lt;- data.frame(x = 1:10, y = sample(1:100, 10, replace = TRUE))
  
  f1 &lt;- function(data, name)
  {
    data[name]
  }
  
  f1(d, "x")
  f1(d, "y")
  </code></pre>
  
  <p>However, instead of providing the column <strong>name</strong> as character string I would like to provide the column as symbol as in this form:</p>
  
  <pre><code>f2(d, x)
  f2(d, y)
  </code></pre>
  
  <p>My question: How is <code>f2</code> to be defined?</p>
  
  <p>Background: This is a simplified example. Actually the function to be defined has this prototype:</p>
  
  <pre><code>fx(d, v, ...)
  </code></pre>
  
  <p>and returns a data frame which sums up<code>v</code> over any column listed in <code>...</code>.</p>