title: R assign column to dataframe with variable name
body: <p>Assign to a dataframe colum with a variable name.</p>
  
  <pre><code>getModified &lt;- function(dframe, destination_string, foo, bar) {
      # complex calculations on foo and bar getting mynewcol here
      # ...
  
      # I want to add mynewcolumn with name in destination_string
      # if "blah" was the destination_string, the result would be as:
      #dframe$blah &lt;- mynewcol
      #return(dframe)
  
      # what is the syntax for using the variable?
      # no luck here:
      dframe[, destination_string] &lt;- mynewcolumn
      return(dframe)
    }
  </code></pre>
  
  <p>so that I could call</p>
  
  <pre><code>dframe &lt;- getModified(dframe, "nameofmynewcolum", foo, bar)
  dframe$nameofmynewcolumn
  </code></pre>