title: How do I calculate accuracy from a decision tree?
body: <p>I've made a decision tree and then made a confusion matrix with it:</p>
  <pre><code>tree1 &lt;- rpart(gen_election ~ twitter + facebook + youtube, data = train_data)
  
  pred &lt;- factor(ifelse(predicted_values[,2] &gt; 0.5, 1,0))
  
  confMatTree1 &lt;- confusionMatrix(pred, test_data$gen_election, positive = levels(test_data$gen_election)[2])
  </code></pre>
  <p>I'm trying to determine the accuracy of the tree.  So far I have tried this code</p>
  <pre><code>accuracyTree1 &lt;- sum(diag(confMatTree1))/sum(confMatTree1)
  </code></pre>
  <p>I'm getting the error &quot; 'list' object cannot be coerced into type 'double' &quot;</p>