With data.table and mltools:
df <- as.data.table(df)
df_oh <- one_hot(df)
Result & Explanation
head(df_oh)
   age education_level marital_status_Divorced marital_status_Married marital_status_Never marital_status_Widowed occupation_Admin occupation_Banking occupation_Farming occupation_Fishing occupation_Poledancing gender_Man gender_Unicorn gender_Woman    hours income_<=50K income_>50K
1:  26              12                       0                      0                    0                      1                0                  0                  0                  0                      1          0              0            1 39.69357            0           1
2:  70              12                       0                      0                    0                      1                0                  0                  0                  0                      1          1              0            0 39.35318            0           1
3:  21              14                       1                      0                    0                      0                1                  0                  0                  0                      0          0              0            1 40.72573            1           0
4:  56               1                       0                      1                    0                      0                0                  1                  0                  0                      0          1              0            0 39.04525            0           1
5:  81               2                       0                      0                    0                      1                0                  0                  1                  0                      0          0              1            0 39.21665            1           0
6:  38               5                       0                      0                    0                      1                1                  0                  0                  0                      0          1              0            0 39.94481            1           0
What one_hot() is doing is taking all factor variables (i.e., not numeric, not character, etc.) of a data table and one-hotting them. It needs a data table (and not, say, a data frame), because data tables provide some features/concepts that help with flexibility and speed.
If you check the documentation under ?one_hot you will see that the function can also treat NAs pretty nicely (if this is a concern in your data).
If you have any questions, please feel free to add a comment.
Reproduction
# Load libraries
library(data.table)
library(mltools)
# Set seed for reproducibility
set.seed(1701)
# Create mock data frame
df <- data.frame(
    age = sample(18:85, 50, replace = TRUE),
    education_level = sample(1:15, 50, replace = TRUE),
    marital_status = sample(c("Never", "Married", "Divorced", "Widowed"), 50, replace = TRUE),
    occupation = sample(c("Admin", "Farming", "Poledancing", "Fishing", "Banking"), 50, replace = TRUE),
    gender = sample(c("Man", "Woman", "Unicorn"), 50, replace = TRUE),
    hours = rnorm(50, 40, 1),
    income = sample(c("<=50K", ">50K"), 50, replace = TRUE))
Resulting in:
> head(df)
  age education_level marital_status  occupation  gender    hours income
1  26              12        Widowed Poledancing   Woman 39.69357   >50K
2  70              12        Widowed Poledancing     Man 39.35318   >50K
3  21              14       Divorced       Admin   Woman 40.72573  <=50K
4  56               1        Married     Banking     Man 39.04525   >50K
5  81               2        Widowed     Farming Unicorn 39.21665  <=50K
6  38               5        Widowed       Admin     Man 39.94481  <=50K