Following is the recipe I am creating where I want to convert few numeric features to factors:
house_recipe <- training(house_split) %>%
recipe(log_sale_price ~ MSSubClass + OverallCond + LowQualFinSF) %>%
step_num2factor(
select(MSSubClass,OverallCond,LowQualFinSF),
levels = list(fct_cd_mssbclass, fct_cd_ovcond, fct_cd_lwqfinsf)
)
I get the following error:
Error: Please provide a character vector of appropriate length for
levels
.
The levels have been passed as list in the code above. The definition of levels
is as follows:
#create levels
fct_cd_mssbclass <- as.character(unique(sort(training(house_split)$MSSubClass)))
fct_cd_ovcond <- as.character(unique(sort(training(house_split)$OverallCond)))
fct_cd_lwqfinsf <- as.character(unique(sort(training(house_split)$LowQualFinSF)))
Please advise how to use this step function correctly. I didn't find any similar example in the documentation. Thanks.