Correct level names for modelling and in the use of ROC curve/AUC.
correct_model_levels(data)
String with level names.
Corrected level names.
data <- data.frame(id = c(1,2,3),
name = c("Alice","Bob","Charlie"),
gender = factor(c("Female","Male","Female"), levels = c("Female","Male")))
correct_model_levels(data)
#> id name gender
#> 1 1 Alice Female
#> 2 2 Bob Male
#> 3 3 Charlie Female
# returns a data frame with factor levels of the variable gender corrected to "Female" and "Male"
data <- data.frame(id = c(1,2,3),
name = c("Alice","Bob","Charlie"),
gender = factor(c("Female","Male","Female")))
correct_model_levels(data)
#> id name gender
#> 1 1 Alice Female
#> 2 2 Bob Male
#> 3 3 Charlie Female
# returns a data frame with factor levels of the variable gender corrected to "F" and "M"