title: Error 'input data must have the same two levels' in F_meas in R?
body: <pre><code>set.seed(1)
  library(caret)
  library(dslabs)
  library(dplyr)
  
  data("tissue_gene_expression")
  y_&lt;-tissue_gene_expression$y
  
  test_index &lt;- createDataPartition(y_, times = 1, ,p=0.5, list = FALSE)
  
  x_train&lt;-tissue_gene_expression$x[-test_index,]
  y_train&lt;-tissue_gene_expression$y[-test_index]
  
  x_test&lt;-tissue_gene_expression$x[test_index,]
  y_test&lt;-tissue_gene_expression$y[test_index]
  
  fit&lt;-knn3(x_train,y_train,k=1)
  y_test_hat&lt;-predict(fit,x_test,type = 'class')
  
  F_meas(data = y_test_hat,reference = y_test)
  </code></pre>
  
  <p>Above is my code, it always return the error:</p>
  
  <pre><code>Error in F_meas.default(data = y_test_hat, reference = y_test, ) :
   input data must have the same two levels
  </code></pre>
  
  <p>although I have check the levels of these two data (<code>y_test_hat</code> and <code>y_test_hat</code>) and they have the same 7 levels</p>