Create dummy variables for categorical data.

rbin_factor_create(data, predictor)

Arguments

data

A data.frame or tibble.

predictor

Variable for which dummy variables must be created.

Value

A tibble with dummy variables.

Examples

upper <- c("secondary", "tertiary") out <- rbin_factor_combine(mbank, education, upper, "upper") rbin_factor_create(out, education)
#> age job marital default balance housing #> 1 34 technician married no 297 yes #> 2 49 services married no 180 yes #> 3 38 admin. single no 262 no #> 4 47 services married no 367 yes #> 5 51 self-employed single no 1640 yes #> 6 40 unemployed married no 3382 yes #> 7 58 retired married no 1227 no #> 8 32 unemployed married no 309 yes #> 9 46 blue-collar married no 922 yes #> 10 32 services married no 0 no #> 11 32 services married no 414 yes #> 12 50 blue-collar married no 0 no #> 13 41 management married no 2226 no #> 14 38 services divorced no 0 yes #> 15 31 self-employed married yes 147 yes #> 16 42 admin. single no 283 yes #> 17 56 retired married no -1 no #> 18 54 management divorced no 901 no #> 19 42 management married no 372 yes #> 20 58 services married no 627 no #> 21 51 admin. married no 26 yes #> 22 44 management married no 438 yes #> 23 51 management single no -461 yes #> 24 41 management married no -195 no #> 25 57 technician married no 16063 yes #> 26 32 management single no 3097 yes #> 27 32 management married no 1232 no #> 28 45 management married no 4693 no #> 29 56 entrepreneur married no 196 no #> 30 38 technician married no 0 yes #> 31 54 self-employed married no 990 no #> 32 53 unemployed single no 183 no #> 33 36 management single no 219 no #> 34 37 blue-collar married no -97 yes #> 35 31 services single no 222 yes #> 36 42 technician married no 234 no #> 37 34 services single no 25 yes #> 38 37 technician married no 1762 no #> 39 59 blue-collar married no 80 yes #> 40 54 management married yes 0 yes #> 41 54 blue-collar married no 1357 yes #> 42 59 admin. married no -198 yes #> 43 33 management single no 2059 no #> 44 24 services single no 258 yes #> 45 29 technician single no 2269 yes #> 46 49 blue-collar married no 0 no #> 47 37 technician married no 77 yes #> 48 28 blue-collar married no 254 yes #> 49 82 retired married no 103 no #> 50 57 blue-collar married no 452 yes #> loan contact day month duration campaign pdays #> 1 no cellular 29 jan 375 2 -1 #> 2 yes unknown 2 jun 392 3 -1 #> 3 no cellular 3 feb 315 2 180 #> 4 no cellular 12 may 309 1 306 #> 5 no unknown 15 may 67 4 -1 #> 6 no unknown 14 may 125 1 -1 #> 7 no cellular 14 aug 182 2 37 #> 8 no telephone 13 may 185 1 370 #> 9 no telephone 18 nov 296 2 -1 #> 10 no cellular 21 nov 80 1 -1 #> 11 no cellular 3 feb 236 2 272 #> 12 no unknown 9 jun 199 4 -1 #> 13 no cellular 7 aug 182 2 99 #> 14 no cellular 20 nov 250 1 155 #> 15 no cellular 11 may 12 5 -1 #> 16 no unknown 19 jun 446 1 -1 #> 17 no cellular 27 aug 89 23 -1 #> 18 no unknown 20 jun 7 3 -1 #> 19 no telephone 31 jul 130 8 -1 #> 20 no cellular 13 aug 110 4 -1 #> 21 no telephone 28 aug 51 3 -1 #> 22 no telephone 9 jul 42 1 -1 #> 23 no unknown 28 may 33 2 -1 #> 24 yes cellular 20 nov 112 1 -1 #> 25 no unknown 30 may 352 3 -1 #> 26 no cellular 20 nov 167 1 -1 #> 27 no cellular 25 aug 97 4 -1 #> 28 yes cellular 9 jul 148 2 -1 #> 29 no cellular 19 nov 312 3 -1 #> 30 no unknown 21 may 73 1 -1 #> 31 no cellular 3 jun 244 2 -1 #> 32 no cellular 9 jun 835 2 -1 #> 33 no cellular 3 feb 22 6 196 #> 34 no unknown 5 jun 135 2 -1 #> 35 no cellular 13 may 168 2 -1 #> 36 no cellular 4 feb 765 2 -1 #> 37 yes cellular 9 apr 96 4 314 #> 38 no cellular 16 apr 334 2 -1 #> 39 no telephone 31 jul 46 21 -1 #> 40 yes cellular 6 may 95 1 -1 #> 41 yes cellular 5 may 305 5 349 #> 42 yes cellular 8 may 206 1 -1 #> 43 no cellular 29 aug 106 2 -1 #> 44 no cellular 18 may 248 1 -1 #> 45 no cellular 20 apr 53 1 346 #> 46 no cellular 14 aug 189 4 -1 #> 47 yes cellular 21 nov 44 1 -1 #> 48 no cellular 20 apr 149 2 -1 #> 49 no cellular 1 sep 368 1 -1 #> 50 no unknown 13 may 139 4 -1 #> previous poutcome y education education_upper #> 1 0 unknown 0 upper 1 #> 2 0 unknown 0 upper 1 #> 3 6 failure 1 upper 1 #> 4 4 success 1 upper 1 #> 5 0 unknown 0 upper 1 #> 6 0 unknown 0 upper 1 #> 7 2 failure 0 upper 1 #> 8 3 failure 0 primary 0 #> 9 0 unknown 0 upper 1 #> 10 0 unknown 0 upper 1 #> 11 1 failure 0 upper 1 #> 12 0 unknown 0 primary 0 #> 13 1 failure 1 upper 1 #> 14 2 failure 0 primary 0 #> 15 0 unknown 0 upper 1 #> 16 0 unknown 0 upper 1 #> 17 0 unknown 0 primary 0 #> 18 0 unknown 0 unknown 0 #> 19 0 unknown 0 upper 1 #> 20 0 unknown 0 upper 1 #> 21 0 unknown 0 upper 1 #> 22 0 unknown 0 upper 1 #> 23 0 unknown 0 unknown 0 #> 24 0 unknown 0 upper 1 #> 25 0 unknown 0 upper 1 #> 26 0 unknown 0 upper 1 #> 27 0 unknown 0 upper 1 #> 28 0 unknown 0 upper 1 #> 29 0 unknown 0 upper 1 #> 30 0 unknown 0 upper 1 #> 31 0 unknown 1 upper 1 #> 32 0 unknown 0 primary 0 #> 33 6 failure 0 upper 1 #> 34 0 unknown 0 upper 1 #> 35 0 unknown 0 upper 1 #> 36 0 unknown 0 upper 1 #> 37 8 other 0 primary 0 #> 38 0 unknown 1 upper 1 #> 39 0 unknown 0 primary 0 #> 40 0 unknown 0 primary 0 #> 41 7 other 0 primary 0 #> 42 0 unknown 0 upper 1 #> 43 0 unknown 0 upper 1 #> 44 0 unknown 0 upper 1 #> 45 1 failure 0 upper 1 #> 46 0 unknown 0 upper 1 #> 47 0 unknown 0 upper 1 #> 48 0 unknown 0 primary 0 #> 49 0 unknown 0 primary 0 #> 50 0 unknown 0 primary 0 #> education_unknown education_primary #> 1 0 0 #> 2 0 0 #> 3 0 0 #> 4 0 0 #> 5 0 0 #> 6 0 0 #> 7 0 0 #> 8 0 1 #> 9 0 0 #> 10 0 0 #> 11 0 0 #> 12 0 1 #> 13 0 0 #> 14 0 1 #> 15 0 0 #> 16 0 0 #> 17 0 1 #> 18 1 0 #> 19 0 0 #> 20 0 0 #> 21 0 0 #> 22 0 0 #> 23 1 0 #> 24 0 0 #> 25 0 0 #> 26 0 0 #> 27 0 0 #> 28 0 0 #> 29 0 0 #> 30 0 0 #> 31 0 0 #> 32 0 1 #> 33 0 0 #> 34 0 0 #> 35 0 0 #> 36 0 0 #> 37 0 1 #> 38 0 0 #> 39 0 1 #> 40 0 1 #> 41 0 1 #> 42 0 0 #> 43 0 0 #> 44 0 0 #> 45 0 0 #> 46 0 0 #> 47 0 0 #> 48 0 1 #> 49 0 1 #> 50 0 1 #> [ reached 'max' / getOption("max.print") -- omitted 4471 rows ]