Skip to contents

Compare the values in multiple items by a metric column that will be split into groups

Usage

tab_counts_items_cor(
  data,
  cols,
  cross,
  category = NULL,
  split = 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

A metric column that will be split into groups at the median value.

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.

split

Not implemented yet.

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_cor(
  data, starts_with("cg_adoption_"), sd_age,
  category=c("agree", "strongly agree")
)
#> 
#> 
#> |Expectations                                                |    total|  Low Age| High Age|
#> |:-----------------------------------------------------------|--------:|--------:|--------:|
#> |ChatGPT has clear advantages compared to similar offerings. | 51% (49)| 58% (26)| 44% (23)|
#> |Using ChatGPT brings financial benefits.                    | 27% (26)| 36% (16)| 19% (10)|
#> |Using ChatGPT is advantageous in many tasks.                | 63% (61)| 69% (31)| 58% (30)|
#> |Compared to other systems, using ChatGPT is more fun.       | 54% (52)| 58% (26)| 50% (26)|
#> |Much can go wrong when using ChatGPT.                       | 35% (34)| 33% (15)| 37% (19)|
#> |There are legal issues with using ChatGPT.                  | 30% (29)| 24% (11)| 35% (18)|
#> |The security of user data is not guaranteed with ChatGPT.   | 33% (32)| 42% (19)| 25% (13)|
#> |Using ChatGPT could bring personal disadvantages.           | 25% (24)| 29% (13)| 21% (11)|
#> |In my environment, using ChatGPT is standard.               | 21% (20)| 31% (14)|  12% (6)|
#> |Almost everyone in my environment uses ChatGPT.             | 16% (16)|  20% (9)|  13% (7)|
#> |Not using ChatGPT is considered being an outsider.          | 12% (12)|  18% (8)|   8% (4)|
#> |Using ChatGPT brings me recognition from my environment.    | 20% (19)| 24% (11)|  15% (8)|
#> 
#> Frequencies based on values: agree, strongly agree. Age split at median 38. 4 missing case(s) omitted.
#>