R: How to Transform “prob” Predictions to a Single Column of Predicted Values

# Recombine Test + Training ———————————————–
a <- cbind(x1, y1)
b <- cbind(x, y)

a$actual <- a$y1
b$actual <- b$y
a$y1     <- NULL
b$y      <- NULL

c <- rbind(a, b)

# Run Predictions for Entire Data Set ————————————-
all_preds <- predict(rf, newdata = c, type = “prob”)

c$predicted <- apply(all_preds, 1, which.max)

then you can replace the column number with the descriptive category name or whatever
NOTE: This is NOT the same result that you’ll get by doing colSums on the “prob” type prediction, however
Stackoverflow Solutions

Just started! Have not answered any questions.