Create dummy variables within a tibble

dummify(dat, sel)

Arguments

dat

A tibble with the data.

sel

A character vector with the name(s) of the variables to be dummied.

Value

tibble with dummy variables

Examples

mytest=data.frame(A=factor(c('a','a','b','c','c')), B=1:5)
dummify(mytest,"A")
#> # A tibble: 5 × 4
#>   `A:a` `A:b` `A:c`     B
#>   <dbl> <dbl> <dbl> <int>
#> 1     1     0     0     1
#> 2     1     0     0     2
#> 3     0     1     0     3
#> 4     0     0     1     4
#> 5     0     0     1     5