Recode a categorical column
Usage
add_recode(.data, .col, .newcol = paste0(col, ".c"), ...)
Arguments
- .data
the data frame
- .col
the column to recode
- .newcol
the name of the recoded column (defaults to col.c)
- ...
coding for categorical column
Examples
add_random(subj = 4, item = 4) %>%
add_between("subj", cond = c("cntl", "test")) %>%
add_recode("cond", "cond.t", cntl = 0, test = 1)
#> # A tibble: 16 × 4
#> subj item cond cond.t
#> <chr> <chr> <fct> <dbl>
#> 1 subj1 item1 cntl 0
#> 2 subj1 item2 cntl 0
#> 3 subj1 item3 cntl 0
#> 4 subj1 item4 cntl 0
#> 5 subj2 item1 test 1
#> 6 subj2 item2 test 1
#> 7 subj2 item3 test 1
#> 8 subj2 item4 test 1
#> 9 subj3 item1 cntl 0
#> 10 subj3 item2 cntl 0
#> 11 subj3 item3 cntl 0
#> 12 subj3 item4 cntl 0
#> 13 subj4 item1 test 1
#> 14 subj4 item2 test 1
#> 15 subj4 item3 test 1
#> 16 subj4 item4 test 1