Andre, bom dia!

Deve funcionar se transformar "X" em factor().

mt@data$X <- as.factor(sample(LETTERS[1:4], size = n, replace=T))

Éder Comunello <comunello.eder@gmail.com>
Dourados, MS - [22 16.5'S, 54 49'W]