title: Calculating accuracy for a regression tree
body: <p>I am trying to calculate the RMSE of a regression tree prediction but keep getting an error.</p>
  
  <p>I have loaded a df, removed all empty records and split my df to training and validation:</p>
  
  <pre><code>income.df &lt;- read.csv("adult.data.csv")
  
  income.df$Workclass &lt;- gsub("[?]", NA, as.character(income.df$Workclass))
  income.df$Workclass &lt;- as.factor(income.df$Workclass)
  income.df$occupation &lt;- gsub("[?]", NA, as.character(income.df$occupation))
  income.df$occupation &lt;- as.factor(income.df$occupation)
  income.df$native.country &lt;- gsub("[?]", NA, as.character(income.df$native.country))
  income.df$native.country &lt;- as.factor(income.df$native.country)
  
  income.sub.df &lt;- na.omit(income.df)
  
  levels(income.sub.df$income) &lt;- c(1,0)
  
  names(income.sub.df)[15] &lt;- "isBelow50k"
  
  train.index2 &lt;- sample(income.sub.df$Age, dim(income.sub.df)[1]*0.6)
  train2.df &lt;- income.sub.df[train.index2, ]
  valid2.df &lt;- income.sub.df[-train.index2, ]
  </code></pre>
  
  <p>Created an rpart tree</p>
  
  <pre><code>library(rpart)
  library(rpart.plot)
  library(forecast)
  
  tr.income &lt;- rpart(isBelow50k ~ ., data = train2.df)
  prp(tr.income)
  predrpart &lt;- predict(tr.income, newdata = valid2.df)
  accuracy(predrpart, valid2.df$isBelow50k)
  </code></pre>
  
  <p>The error I keep getting is:</p>
  
  <pre><code>Error in accuracy(predrpart, valid2.df$isBelow50k) : 
    First argument should be a forecast object or a time series.
  </code></pre>
  
  <p>I have tried converting it to a vector but nothing seems to do the trick.</p>