I have used recipe()function in tidymodels packages for imputation missing values and fixing imbalanced data.
recipe()
tidymodels
here is my data;