title: Error in eval(predvars, data, env) : object 'Rm' not found
body: <pre><code>dataset = read.csv('dataset/housing.header.binary.txt')
  dataset1 = dataset[6] #higest positive correlation
  dataset2 = dataset[13] #lowest negative correlation
  dependentVal= dataset[14] #dependent value
  new_dataset = cbind(dataset1,dataset2, dependentVal) # new matrix 
  
  #split dataset
  #install.packages('caTools')
  library(caTools)
  
  set.seed(123) #this is needed to garantee that every run will produce the same output
  split = sample.split(new_dataset, SplitRatio = 0.75)
  train_set = subset(new_dataset, split == TRUE)
  test_set = subset(new_dataset, split == FALSE)
  
  
  #Fitting Decision Tree to training set
  install.packages('rpart')
  library(rpart)
  classifier = rpart(formula = Medv ~ Rm + Lstat,
                     data = train_set)
  
  #predicting the test set results
  y_pred = predict(classifier, newdata = test_set[3], type ='class')
  </code></pre>
  
  <p>I want to predict column 3 of <code>test_set</code>, but I keep getting <br></p>
  
  <blockquote>
    <p>Error in eval(predvars, data, env) : object 'Rm' not found</p>
  </blockquote>
  
  <p>Even though I specify <code>test_set[3]</code> not <code>test_set[1]</code> which contain <code>Rm</code></p>
  
  <p>The column names are as follows: <code>Rm</code>, <code>Lstat</code>, and <code>Medv</code>.</p>
  
  <p><code>test_set[3]</code> and <code>test_set[2]</code> give the same following error: </p>
  
  <blockquote>
    <p>Error in eval(predvars, data, env) : object Rm not found</p>
  </blockquote>
  
  <p>and <code>test_set[1]</code> gives: </p>
  
  <blockquote>
    <p>Error in eval(predvars, data, env) : object 'Lstat' not found</p>
  </blockquote>
  
  <p>I have tried the following:</p>
  
  <ol>
  <li><code>names(test_set) &lt;- c('Rm', 'Lstat','Medv')</code>: I renamed explicitly.</li>
  <li><code>is.data.frame(test_set)</code>: i checked if test_set is a dataframe.</li>
  </ol>