Skip to content
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

{p_miss} from add_n() when combined with by statement #903

Closed
tamytsujimoto opened this issue May 18, 2021 · 1 comment · Fixed by #904
Closed

{p_miss} from add_n() when combined with by statement #903

tamytsujimoto opened this issue May 18, 2021 · 1 comment · Fixed by #904

Comments

@tamytsujimoto
Copy link

Hi there!
Loving this package, but I wonder if there is any bug when trying to display the missing % for a categorical variable using the add_n() function combined with the by statement:

data.frame(x = c(1,2,NA, NA, NA, 1, 2, 1),
y = c(rep(0,4), rep(1,4))) %>%
tbl_summary(by = y) %>%
add_n(statistic = "{n_miss}/{N} = {p_miss}%")

In this case we should have 3/8 = 38%, but here it is displaying 75%.
It only happens if we use the by statement, as if works just fine when I use:

data.frame(x = c(1,2,NA, NA, NA, 1, 2, 1),
y = c(rep(0,4), rep(1,4))) %>%
select(x) %>%
tbl_summary() %>%
add_n(statistic = "{n_miss}/{N} = {p_miss}%")

Thanks in advance!
Tamy

ddsjoberg added a commit that referenced this issue May 18, 2021
@ddsjoberg ddsjoberg mentioned this issue May 18, 2021
14 tasks
@ddsjoberg
Copy link
Owner

@tamytsujimoto thank you so much for letting me know!

the correction will be available in the main branch soon!

ddsjoberg added a commit that referenced this issue May 18, 2021
* #903 fix

* increment version number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants