Error in table(data, reference, dnn = dnn, ...) : all arguments must have the same length error while making confusion matrix.

Hi, and welcome!

I'm sure that you have heard of lazy evaluation in R. The same principle applies in the community here, which is why a reproducible example, called a reprex is important. The question will attract more and better answers.