Skip to contents

This function converts a frequency table to a tibble or data frame. It also creates a proportion variable as well as the frequency variable.

Usage

table_to_tibble(tab, tibble = TRUE)

Arguments

tab

A frequency table.

tibble

A logical value indicating whether the output should be a tibble or data frame. Default is TRUE.

Value

A tibble or data frame, depending on the tibble argument.

Examples

tab <- lapply(combinat::permn(seq(3)), paste0, collapse = "") |>
  sample(30, replace = TRUE) |>
  unlist() |>
  table()
table_to_tibble(tab)
#> # A tibble: 6 × 3
#>   ranking  freq  prop
#>   <fct>   <dbl> <dbl>
#> 1 123         5 0.167
#> 2 132         5 0.167
#> 3 213         6 0.2  
#> 4 231         3 0.1  
#> 5 312         8 0.267
#> 6 321         3 0.1