Skip to contents

Given a rack shelf, or in other words, row of a model rack, calculate segmentation attribute summary. Result is returned in a form of a dataframe.

Usage

shelf_make_feature_counts(
  shelf,
  data = "data$x",
  cols = everything(),
  na.rm = TRUE
)

Arguments

shelf

A rack shelf, or in other words, a row of a model rack extracted with rack_extract_shelf().

data

One of the following:

  • "data$x" to use model features for indices

  • A name of a column containing dataframe to use its columns for indices

  • a dataframe to take index columns from

cols

A tidyselect expression to subset columns from data. By default is everything(), so all columns are taken.

na.rm

Drop NA categories before calculating percentages? Default is FALSE.

Examples

shelf_make_feature_counts(shelf = example_seg_shelf)
#> ! Found 4 columns with missing or invalid labels: "weight", "segment", "name", and "value".
#> ℹ Replacing these labels with {.code NA_character_}
#> # A tibble: 12 × 6
#> # Groups:   Response Option [4]
#>    `Response Option` Stat         Yellow       Red    Green  Overall
#>    <fct>             <chr>      <p_xlsx>  <p_xlsx> <p_xlsx>    <dbl>
#>  1 Strongly disagree Index       [34.66]   [152.6]  [63.55]  100    
#>  2 Strongly disagree Percentage   [0.04]    [0.16]   [0.07]    0.102
#>  3 Strongly disagree N           [45.37]  [419.05]  [102.7]  567.   
#>  4 Somewhat disagree Index      [116.02]   [89.82] [104.33]  100    
#>  5 Somewhat disagree Percentage   [0.24]    [0.19]   [0.22]    0.207
#>  6 Somewhat disagree N          [307.09]  [498.71] [340.94] 1147.   
#>  7 Somewhat agree    Index      [114.03]   [86.94] [110.82]  100    
#>  8 Somewhat agree    Percentage   [0.49]    [0.38]   [0.48]    0.434
#>  9 Somewhat agree    N          [632.04] [1010.85] [758.35] 2401.   
#> 10 Strongly agree    Index       [89.45]  [109.29]  [92.77]  100    
#> 11 Strongly agree    Percentage   [0.23]    [0.28]   [0.24]    0.257
#> 12 Strongly agree    N          [293.58]  [752.44] [375.91] 1422.