score_from_lv1 {tabxplor} | R Documentation |
Create a score variable from factors
Description
Create a score variable from factors
Usage
score_from_lv1(data, name, vars_list)
Arguments
data |
A data.frame. |
name |
The name of the variable to create. |
vars_list |
The list of the factors to count (only the first level is counted, as 1) ; as a character vector. |
Value
The data.frame, with a new variable.
Examples
data <- tibble::tibble(group = factor(c("G1", "G1", "G2", "G2", "G3", "G3")),
a = factor(c("Oui", "Oui", "Oui", "Oui", "Non", "Oui")),
b = factor(c("Oui", "Non", "Non", "Oui", "Non", "Oui")),
c = factor(c("Oui", "Oui", "Non", "Non", "Oui", "Oui")))
data |>
score_from_lv1("score", vars_list = c("a", "b", "c")) |>
tab(group, score, digits = 1)
[Package tabxplor version 1.3.0 Index]