Skip to contents

Compare the values in multiple items by a grouping column

Usage

tab_counts_items_grouped(
  data,
  cols,
  cross,
  category = NULL,
  percent = TRUE,
  values = c("n", "p"),
  title = TRUE,
  labels = TRUE,
  clean = TRUE,
  ...
)

Arguments

data

A tibble containing item measures.

cols

Tidyselect item variables (e.g. starts_with...).

cross

The column holding groups to compare.

category

Summarizing multiple items (the cols parameter) by group requires a focus category. By default, for logical column types, only TRUE values are counted. For other column types, the first category is counted. Accepts both character and numeric vectors to override default counting behavior.

percent

Proportions are formatted as percent by default. Set to FALSE to get bare proportions.

values

The values to output: n (frequency) or p (percentage) or both (the default).

title

If TRUE (default) shows a plot title derived from the column labels. Disable the title with FALSE or provide a custom title as character value.

labels

If TRUE (default) extracts labels from the attributes, see codebook.

clean

Prepare data by data_clean.

...

Placeholder to allow calling the method with unused parameters from plot_counts.

Value

A volker tibble.

Examples

library(volker)
data <- volker::chatgpt
tab_counts_items_grouped(
  data, starts_with("cg_adoption_"), adopter,
  category=c("agree", "strongly agree")
)
#> 
#> 
#> |Expectations                                                |    total| I try new offers immediately| I try new offers rather quickly| I wait until offers establish themselves| I only use new offers when I have no other choice|
#> |:-----------------------------------------------------------|--------:|----------------------------:|-------------------------------:|----------------------------------------:|-------------------------------------------------:|
#> |ChatGPT has clear advantages compared to similar offerings. | 51% (49)|                      53% (8)|                        51% (31)|                                 50% (10)|                                            0% (0)|
#> |Using ChatGPT brings financial benefits.                    | 27% (26)|                      53% (8)|                        26% (16)|                                  10% (2)|                                            0% (0)|
#> |Using ChatGPT is advantageous in many tasks.                | 63% (61)|                     73% (11)|                        66% (40)|                                 50% (10)|                                            0% (0)|
#> |Compared to other systems, using ChatGPT is more fun.       | 54% (52)|                     67% (10)|                        49% (30)|                                 60% (12)|                                            0% (0)|
#> |Much can go wrong when using ChatGPT.                       | 35% (34)|                      33% (5)|                        38% (23)|                                  30% (6)|                                            0% (0)|
#> |There are legal issues with using ChatGPT.                  | 30% (29)|                      47% (7)|                        31% (19)|                                  15% (3)|                                            0% (0)|
#> |The security of user data is not guaranteed with ChatGPT.   | 33% (32)|                      60% (9)|                        30% (18)|                                  25% (5)|                                            0% (0)|
#> |Using ChatGPT could bring personal disadvantages.           | 25% (24)|                      47% (7)|                        23% (14)|                                  15% (3)|                                            0% (0)|
#> |In my environment, using ChatGPT is standard.               | 21% (20)|                     67% (10)|                         13% (8)|                                  10% (2)|                                            0% (0)|
#> |Almost everyone in my environment uses ChatGPT.             | 16% (16)|                      60% (9)|                         10% (6)|                                   5% (1)|                                            0% (0)|
#> |Not using ChatGPT is considered being an outsider.          | 12% (12)|                      53% (8)|                          5% (3)|                                   5% (1)|                                            0% (0)|
#> |Using ChatGPT brings me recognition from my environment.    | 20% (19)|                      53% (8)|                         13% (8)|                                  15% (3)|                                            0% (0)|
#> 
#> Frequencies based on values: agree, strongly agree. 4 missing case(s) omitted.
#>