title: Passing character as variable name in R
body: <p>I am trying to solve an implicit equation in R using <code>multiroot</code> function from package <code>rootSolve</code>.</p>
  
  <p>I am reading the implicit equation from a text file using <code>parse</code>. Also, the variable to be solved for is read from a text file as a character.</p>
  
  <p>For using <code>multiroot</code>,</p>
  
  <pre><code>multiroot(function, initial_guess, ....))
  </code></pre>
  
  <p>we have to generate a function from the read equation. I did this by </p>
  
  <pre><code>fun &lt;- function(op) {fun &lt;- eval(expr.im)}
  op = as.name(opim.names)
  </code></pre>
  
  <p>where <code>expr.im</code> is the read implicit equation as an expression from the text file, and <code>opim.names</code> is the variable to be solved for, as character.</p>
  
  <p>But the problem arises when I pass the variable <code>op</code> to be solved as a symbol to the function. It gives an error saying that the object</p>
  
  <blockquote>
    <p>"variable to be solved for" not found.</p>
  </blockquote>
  
  <p>I think that the variable symbol is not being passed correctly in the function.</p>
  
  <p>Please tell me how to do it correctly.</p>
  
  <p>Since a lot of stuff is going on in my code, I cannot post the whole thing here.
  Let me just state a small example for it.</p>
  
  <pre><code>var.name = "x1" # This is what I read from the text file #
  var.sym = as.name(var.name)
  
  func &lt;- function(var.sym){
  func = x1^2      # the expression x1^2 is also read from a text file  #
  }                  # I am trying to solve the implicit equation x1^2 = 0  #
  initial_guess = 1
  root = multiroot(f=func, start = initial_guess)
  </code></pre>
  
  <p>As requested by nicola here's what I want - 
  I have a text file giving me the name of the variable and its initial guess.
  I read the variable name (say "x") and the initial guess value (say 1) into variables <code>var</code> (character) and <code>guess</code>(numeric).
  I also have another text file containing the following equation - </p>
  
  <pre><code>x^3-1
  </code></pre>
  
  <p>I read this as an expression in the variable <code>expr</code>.  </p>
  
  <p>I want to find the solution to the implicit equation <code>expr</code>.
  (The text files can have different names of variables and correspondingly an implicit expression in another file)</p>
  
  <p>As you know, for using the multiroot function, we need to have a function.
  The problem is I am not able to pass the variable name stored in <code>var</code> to the function.</p>
  
  <p>Any further clarification will be given if asked.</p>