Open Crismoc opened 1 year ago
Could you pls show what would be the desired resulting df?
I would expect to get something like this:
library(summarytools)
library(dplyr)
tobacco |>
group_by(smoker) |>
reframe(
level = names(table(diseased)),
Freq = table(diseased),
`% Valid` = prop.table(table(diseased)))
#> # A tibble: 4 × 4
#> smoker level Freq `% Valid`
#> <fct> <chr> <table[1d]> <table[1d]>
#> 1 Yes Yes 125 0.4194631
#> 2 Yes No 173 0.5805369
#> 3 No Yes 99 0.1410256
#> 4 No No 603 0.8589744
I see what you mean. The proportions are recalculated to take into account both groups, and it can create confusion. Aside from better documenting this, I think an additional parameter is in order. That way the user can decide whether to recalculate proportions or not. Thank you for pointing it out.
After getting results from a grouped
freq()
, I would like to put them in an object with tibble or data.frame format. When usingtb()
the results are transformed in what might be unintended behavior:Created on 2023-04-19 with reprex v2.0.2
Is there a way to transform the same results to a tibble or data.frame?