title: R: trouble assigning values to a dynamic variable in a dataframe
body: <p>I am trying to assign values to a dataframe variable defined by the user.  The user specifies the name of the variable, let's call this x, in the dataframe df. For simplicity I want to assign a value of 3 to everything in the column the user specifies. The simplified code is:</p>
  
  <pre><code>variableName &lt;- paste("df$", x, sep="")
  eval(parse(text=variableName)) &lt;- 3
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>Error in file(filename, "r") : cannot open the connection</p>
    
    <p>In addition: Warning message:</p>
    
    <p>In file(filename, "r") :
      cannot open file 'df$x': No such file or directory</p>
  </blockquote>
  
  <p>I've tried all kinds of remedies to no avail.  If I simply try to print the values of the column.</p>
  
  <pre><code>eval(parse(text=variableName)) 
  </code></pre>
  
  <p>I get no errors and it prints out ok.  It's only when I try to give that column a value that I get the error.  Any help would be appreciated.</p>