-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change of results when using tb() in grouped freq() #185
Comments
Could you pls show what would be the desired resulting df? |
dcomtois
added
the
Need more info
Clarify / Elaborate / illustrate desired results
label
Aug 20, 2023
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. |
dcomtois
removed
the
Need more info
Clarify / Elaborate / illustrate desired results
label
Nov 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
The text was updated successfully, but these errors were encountered: