In this tutorial, I tried to use another method for converting categorical variables to factor.
In the article, the following method is used.
library(MASS)
library(rpart)
cols <- c('low', 'race', 'smoke', 'ht', 'ui')
birthwt[cols] <- lapply(birthwt[cols], as.factor)
and I replaced the last line by
birthwt[cols] <- as.factor((birthwt[cols]))
but the result is NA all
What is wrong with that?