title: writing a function to draw a decision tree in R
body: <p>I have written the function:  </p>
  
  <pre><code>dec.Tree &lt;- function(subject, formula, dfName, treePackage) {
  if(treePackage == tree) library(tree)
  if(treePackage == tree) churn.tree &lt;- tree(subject ~ formula, dfName)
  if(treePackage == tree) plot(churn.tree, main ="Churn Tree using tree package")
  if(treePackage == tree) text(churn.tree)
  }
  </code></pre>
  
  <p>When I run the function code it creates the function no problem, but when I call the function using the code..</p>
  
  <pre><code>dec.Tree(Churn, ., cust.Churn, tree)
  </code></pre>
  
  <p>It returns the error message:</p>
  
  <blockquote>
    <p>Error in treePackage == tree  :    comparison (1) is possible only for
    atomic and list types</p>
  </blockquote>