Prints descriptive statistics for binomial variables
Source:R/summary_statistics.R
print_binomial.RdCalculates and prints frequency counts and percentages for binomial (two-level) categorical variables.
Value
A tibble with one row per level for each categorical level containing the following columns:
- Variables
Character vector specifying the name of each variable.
- Levels
Character vector specifying the category level for each variable.
- Statistics
Character vector combining the frequency count and the percentage for each level.
Examples
x <- data.frame(A = sample(c("X", "Y"), 100, replace = TRUE))
print_binomial(x)
#> # A tibble: 2 × 3
#> Variables Levels Statistics
#> <chr> <chr> <chr>
#> 1 A X 49 (49%)
#> 2 A Y 51 (51%)
print_binomial(x, digits = 2, width = 5)
#> # A tibble: 2 × 3
#> Variables Levels Statistics
#> <chr> <chr> <chr>
#> 1 A X "49\n(49%)"
#> 2 A Y "51\n(51%)"