title: env=baseenv() in R
body: <p>I've been playing around with the Life Analytics trading with R tutorial (<a href="http://lifeanalytics.blogspot.com/2011/01/forex-trading-with-r-part-1.html" rel="nofollow noreferrer">http://lifeanalytics.blogspot.com/2011/01/forex-trading-with-r-part-1.html</a>) and keep getting stuck on a problem related to building the data model.</p>
  
  <p>So I start with a bunch of functions:</p>
  
  <pre><code>myATR &lt;- function(x) ATR(HLC(atrx))[,'atr']
  mySMI &lt;- function(x) SMI(HLC(smix))[,'SMI']
  myADX &lt;- function(x) ADX(HLC(x))[,'ADX']
  .
  .
  </code></pre>
  
  <p>Then try to build a model passing the data to the functions:</p>
  
  <pre><code>data.model &lt;- specifyModel(myATR(AUDCAD)+mySMI(AUDCAD)...)
  </code></pre>
  
  <p>And keep getting the following error:</p>
  
  <blockquote>
    <p>Error in formula.default(object, env = baseenv()) : invalid formula</p>
  </blockquote>
  
  <p>I've read the following post, but do not understand it well enough to implement a solution:
  <a href="https://stackoverflow.com/questions/8998884/formula-error-inside-function">formula error inside function</a></p>
  
  <p>Can anyone explain this in simpler terms? I need some help getting my hook into understanding environments better.</p>