I need to replace integer variable to factor using this statement below I can accomplish my goal.
training$v1 <- factor(training$v1)
But I have 100 of these v1 to v100 : I’m trying to do the loop on this using this code .. but it gave me error.
for (i in 1:100) {
training$vi <-factor(training$vi)
}
Any recommendation?
Thanks
You could try this inside the for loop
or use column index instead. For instance, the columns you want to modify are from 2:101