Output of machine learning classification prediction on out-of-sample data has too few observations
The actual predictions can be found in newdata.pred$data.
Note that mlr is no longer maintained:

{mlr} is considered retired from the mlr-org team. We won’t add new
features anymore and will only fix severe bugs. We suggest to use the
new mlr3 framework from now on and for future projects.

See the docs: https://mlr.mlr-org.com/
library(mlr)
library(ISLR)

df = ISLR::Auto
df$cylinders = as.factor(df$cylinders)
df$name &lt;- NULL

task = makeClassifTask(data = df, target = &quot;cylinders&quot;)
mod = train(&quot;classif.randomForest&quot;, task)

newdata.pred = predict(mod, newdata = df)
result = data.frame(newdata.pred$data)

    truth response
1       8        8
2       8        8
3       8        8
4       8        8
5       8        8
6       8        8
7       8        8
8       8        8
9       8        8
10      8        8
11      8        8
12      8        8
...