yspec_add_factors.RdAdd factors to data set based on spec information
yspec_add_factors(.data, .spec, ..., .suffix = getOption("ys.fct.suffix", "_f")) yspec_make_factor(values, x)
| .data | the data set to modify |
|---|---|
| .spec | a yspec object |
| ... | unquoted column names for modification |
| .suffix | used to make the column name for the factors |
| values | a vector of values to convert to a factor |
| x | a ycol object |
Note that `.suffix` can be chosen using option `ys.fct.suffix`.
#> [1] female male female female female male #> Levels: male femaledata <- data.frame(SEX = c(1,1,1,1,0,0,1,1), STUDY= c(202,100)) yspec_add_factors(data, spec, SEX, STUDY)#> SEX STUDY SEX_f #> 1 1 202 female #> 2 1 100 female #> 3 1 202 female #> 4 1 100 female #> 5 0 202 male #> 6 0 100 male #> 7 1 202 female #> 8 1 100 female #> STUDY_f #> 1 The first phase 2 study conducted only at sites 1, 2, 3 when the formulation was still oral liquid only #> 2 The first phase 1 study #> 3 The first phase 2 study conducted only at sites 1, 2, 3 when the formulation was still oral liquid only #> 4 The first phase 1 study #> 5 The first phase 2 study conducted only at sites 1, 2, 3 when the formulation was still oral liquid only #> 6 The first phase 1 study #> 7 The first phase 2 study conducted only at sites 1, 2, 3 when the formulation was still oral liquid only #> 8 The first phase 1 study