Search code examples
rdimensions

How do I correct the dimensions on my variable?


I'm attempting to eventually make a confusion matrix in order to check the accuracy of the findings. However, I'm getting an error concerning the dimensions in a variable.

> predval <- predict(t1, test_data)
> head(predval)
 
> pred <- factor(ifelse(predval[,2] > 0.5, 1,0))
Error in predval[, 2] : incorrect number of dimensions
> typeof(predval)
[1] "double"
> dim(predval)
NULL

What am I missing?


Solution

  • It is a named vector soo it doesn't have those dimension

     factor(ifelse(predicted_values > 0.5, 1,0))