title: I am not able to generate the confusion matrix of a classification with One Class in R
body: <p>I am trying to understand and implement One Class Classification in R on dataset in Kaggle(<a href="https://www.kaggle.com/uciml/breast-cancer-wisconsin-data" rel="nofollow noreferrer">https://www.kaggle.com/uciml/breast-cancer-wisconsin-data</a>).</p>
  
  <p>When trying to print a confusion matrix you are giving the error:</p>
  
  <p><code>Error in! All.equal (nrow (data), ncol (data)): invalid type argument</code></p>
  
  <p>What am I doing wrong?</p>
  
  <pre><code>library(caret)
  library(dplyr)
  library(e1071)
  library(NLP)
  library(tm)
  library(data.table)
  
  ds = read.csv('C:/Users/hugos/Desktop/FS Dataset/Health/data_cancer.csv', 
                header = TRUE)
  
  mycols &lt;- c("id","diagnosis","radius_mean","texture_mean","perimeter_mean","area_mean",              
               "smoothness_mean","compactness_mean","concavity_mean",         
               "concave.points_mean","symmetry_mean","fractal_dimension_mean", 
               "radius_se","texture_se","perimeter_se",           
               "area_se","smoothness_se","compactness_se",         
               "concavity_se","concave.points_se","symmetry_se",            
               "fractal_dimension_se","radius_worst","texture_worst",          
               "perimeter_worst","area_worst","smoothness_worst",       
               "compactness_worst","concavity_worst","concave.points_worst",   
               "symmetry_worst","fractal_dimension_worst")
  
  #Convert to numeric
  setDT(ds)[, (mycols) := lapply(.SD, as.numeric), .SDcols = mycols]
  
  #Convert classification to logical
  data &lt;- ds[,.(id,radius_mean,texture_mean,perimeter_mean,area_mean,smoothness_mean,compactness_mean,concavity_mean,concave.points_mean,symmetry_mean,fractal_dimension_mean,radius_se,texture_se,perimeter_se,area_se,smoothness_se,compactness_se,concavity_se,concave.points_se,symmetry_se,fractal_dimension_se,radius_worst,texture_worst,perimeter_worst,area_worst,smoothness_worst,compactness_worst,concavity_worst,concave.points_worst,symmetry_worst,fractal_dimension_worst,diagnosis = ds$diagnosis == "TRUE")]
  
  dataclean &lt;- na.omit(data)
  
  #Separating train and test
  inTrain&lt;-createDataPartition(1:nrow(dataclean),p=0.7,list=FALSE)
  train&lt;- dataclean[inTrain]
  test &lt;- dataclean[-inTrain]
  
  
  svm.model&lt;-svm(diagnosis ~ id+radius_mean+texture_mean+perimeter_mean+area_mean+smoothness_mean+compactness_mean+concavity_mean+concave.points_mean+symmetry_mean+fractal_dimension_mean+radius_se+texture_se+perimeter_se+area_se+smoothness_se+compactness_se+concavity_se+concave.points_se+symmetry_se+fractal_dimension_se+radius_worst+texture_worst+perimeter_worst+area_worst+smoothness_worst+compactness_worst+concavity_worst+concave.points_worst+symmetry_worst+fractal_dimension_worst, data = train,
                 type='one-classification',
                 trControl = fitControl,
                 nu=0.10,
                 scale=TRUE,
                 kernel="radial",
                 metric = "ROC")
  
  #Perform predictions 
  svm.predtrain&lt;-predict(svm.model,train)
  svm.predtest&lt;-predict(svm.model,test)
  
  confTrain &lt;- table(Predicted=svm.predtrain,
                     Reference=train$diagnosis[as.integer(names(svm.predtrain))])
  confTest &lt;- table(Predicted=svm.predtest,
                    Reference=test$diagnosis[as.integer(names(svm.predtest))])
  
  confusionMatrix(confTest,positive='TRUE')
  
  print(confTrain)
  print(confTest)
  </code></pre>