title: How to pass a string as a parameter to a function which expects a variable in R
body: <p>The first call to the function f works, the second does not. How can I pass a String ("v") to the function f so that the function works as exspected?</p>
  
  <pre><code>library(data.table)
  
  f&lt;-function(t,x) t[,deparse(substitute(x)),with=F]
  
  dat&lt;-data.table(v="a")
  
  f(dat,v)
  #    v
  # 1: a
  
  f(dat,eval(parse(text="v")))
  # Error in `[.data.table`(t, , deparse(substitute(x)), with = F) : 
  #   column(s) not found: eval(parse(text = "v")) 
  </code></pre>