income <- read.csv("https://raw.githubusercontent.com/selva86/datasets/master/income.csv")

incomeR <- income %>%
mutate(INCOME = if_else(INCOME == "-10.000)", "Under 30k",
if_else(INCOME == "[10.000–15.000)", "Under 30k",
if_else(INCOME == "[15.000–20.000)", "Under 30k",
if_else(INCOME == "[20.000–25.000)", "Under 30k",
if_else(INCOME == "[25.000–30.000)", "Under 30k", 'Over 30k')))))) %>% mutate_if(is.factor, fct_explicit_na, na_level = 'Unknown') %>%
mutate(INCOME = as.factor(INCOME))

#As for the first example we will quickly build a test and training (or validation) set:

set.seed(100)

incomeR <- incomeR[sample(nrow(incomeR)),]
train <- sample(nrow(incomeR), 0.7*nrow(incomeR), replace = FALSE)
TrainSet <- incomeR[train,]
TestSet <- incomeR[-train,]