-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Is there a mechanism for extracting the proportions from a data_tabulate() object? This would be useful for report writing/automating reports.
For example, I have a contingency table to which I add column proportions:
dance_tib <- discovr::cat_dance
prop_dance <- dance_tib |>
datawizard::data_tabulate(select = "training", by = "dance", proportions = "column", remove_na = TRUE)
# display the table
prop_dance |>
insight::display()| training | No | Yes | Total |
|---|---|---|---|
| Food | 10 (8.1%) | 28 (36.8%) | 38 |
| Affection | 114 (91.9%) | 48 (63.2%) | 162 |
| Total | 124 | 76 | 200 |
Created on 2025-09-17 with reprex v2.1.1
Let's say I want to report these proportions in my automated quarto doc as either the raw proportions or percentages, it'd be handy to extract them directly from prop_dance. I've tried as.table() and as.data.frame() but these return only the frequencies and prop_dance itself appears to be a printed object so stores no info. Is there an easystats function that will extract the proportions for me? Better still, could data_tabulate() be changed so that it creates an object that stores the info in the table and format_table()/display()/print_md() etc are the mechanisms through which the information is then formatted/printed?