title: Error in eval(expr, envir, enclos) : object 'V2' not found
body: <p>Why am I attaining this error?
  It appears my svm classifier worked based on the output, however the rest does not work. I have attempted this with the given iris dataset from R, and the code below worked perfectly. However, when trying to run with the loaded data set it does not. </p>
  
  <p>error: </p>
  
  <pre><code>Error in eval(expr, envir, enclos) : object 'V2' not found
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>balance_data = read.table(file.choose(), sep=",")
  str(balance_data)
  x &lt;- balance_data[, c(2,3,4,5)]
  y &lt;- balance_data[,1]
  X_train &lt;-head(x,500)
  Y_train &lt;- head(y,100)
  X_test &lt;-tail(x,122)
  
  
  decisionTree_Learnruntime = c()
  svm_Learnruntime = c()
  naivebayes_Learnruntime = c()
  knn_Learnruntime = c()
  
  decisionTree_Predictruntime = c()
  svm_Predictruntime = c()
  naivebayes_Predictruntime =c()
  knn_Predictruntime = c()
  
  
  for (i in 1:20){
    library(e1071)
    library(caret)
    #SVM Model
    start.time &lt;- Sys.time()
    svm_model &lt;- svm(X_train,Y_train)
    end.time &lt;- Sys.time()
    time.taken &lt;- end.time - start.time
    svm_Learnruntime [i]&lt;- time.taken
  
    #Prediction Time
    start.time &lt;- Sys.time()
    pred &lt;- predict(svm_model,X_test)
    end.time &lt;- Sys.time()
    time.taken &lt;- end.time - start.time
    svm_Predictruntime [i]&lt;- time.taken
  
    library(rpart)
    #Decision Tree
    #Learn Time
    start.time &lt;- Sys.time()
    tree_model &lt;- rpart(X_train,Y_train)
    end.time &lt;- Sys.time()
    time.taken &lt;- end.time - start.time
    decisionTree_Learnruntime [i]&lt;- time.taken
  
    #Prediction Time 
    start.time &lt;- Sys.time()
    pred = predict(tree_model,X_test)
    end.time &lt;- Sys.time()
    time.taken &lt;- end.time - start.time
    decisionTree_Predictruntime[i] &lt;- time.taken
  
  
    #Naive Bayes
    #Learn Time
    start.time &lt;- Sys.time()
    naive_model &lt;-naiveBayes(X_train,Y_train)
    end.time &lt;- Sys.time()
    time.taken &lt;- end.time - start.time
    naivebayes_Learnruntime [i]&lt;- time.taken
  
    #Prediction Time
    start.time &lt;- Sys.time()
    pred &lt;- predict(naive_model,X_test)
    end.time &lt;- Sys.time()
    time.taken &lt;- end.time - start.time
    naivebayes_Predictruntime [i]&lt;- time.taken
  
  }
  
  mean(svm_Learnruntime)
  mean(svm_Predictruntime)
  decisionTree_Learnruntime
  decisionTree_Predictruntime
  naivebayes_Learnruntime
  naivebayes_Predictruntime
  </code></pre>
  
  <p>output</p>
  
  <pre><code>&gt; mean(svm_Learnruntime)
  [1] 0.01403713
  &gt; mean(svm_Predictruntime)
  [1] 0.001003027
  &gt; decisionTree_Learnruntime
  NULL
  &gt; decisionTree_Predictruntime
  NULL
  &gt; naivebayes_Learnruntime
  NULL
  &gt; naivebayes_Predictruntime
  NULL
  </code></pre>
  
  <p>structure</p>
  
  <pre><code>&gt; str(balance_data)
  'data.frame':   625 obs. of  5 variables:
   $ V1: Factor w/ 3 levels "B","L","R": 1 3 3 3 3 3 3 3 3 3 ...
   $ V2: int  1 1 1 1 1 1 1 1 1 1 ...
   $ V3: int  1 1 1 1 1 1 1 1 1 1 ...
   $ V4: int  1 1 1 1 1 2 2 2 2 2 ...
   $ V5: int  1 2 3 4 5 1 2 3 4 5 ...
  &gt; str(X_train)
  'data.frame':   500 obs. of  4 variables:
   $ V2: int  1 1 1 1 1 1 1 1 1 1 ...
   $ V3: int  1 1 1 1 1 1 1 1 1 1 ...
   $ V4: int  1 1 1 1 1 2 2 2 2 2 ...
   $ V5: int  1 2 3 4 5 1 2 3 4 5 ...
  &gt; str(X_test)
  'data.frame':   122 obs. of  4 variables:
   $ V2: int  5 5 5 5 5 5 5 5 5 5 ...
   $ V3: int  1 1 1 1 1 1 1 1 1 1 ...
   $ V4: int  1 1 2 2 2 2 2 3 3 3 ...
   $ V5: int  4 5 1 2 3 4 5 1 2 3 ...
  &gt; str(Y_train)
   Factor w/ 3 levels "B","L","R": 1 3 3 3 3 3 3 3 3 3 ...
  </code></pre>