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

add_p throws error if all values are NA for a column #889

Closed
fh-jsnider opened this issue May 4, 2021 · 2 comments · Fixed by #891
Closed

add_p throws error if all values are NA for a column #889

fh-jsnider opened this issue May 4, 2021 · 2 comments · Fixed by #891

Comments

@fh-jsnider
Copy link

In 1.4.0, if all values are missing for a given column, instead of not producing a p-value, adding a p-value with add_p() returns an unhelpful error message:

 library(tidyverse)
 mtcars %>% 
 mutate(error_var = NA) %>%
 gtsummary::tbl_summary(by = "cyl") %>% 
 gtsummary::add_p()
#> Error: Problem with `mutate()` input `test_name`.
#> x Result 11 must be a single string, not NULL of length 0
#> ℹ Input `test_name` is `map_chr(.data$test_info, ~pluck(.x, "test_name"))`.

Created on 2021-05-04 by the reprex package (v0.3.0)

Previous versions of gtsummary would give a warning message around the impossibility of creating a p-value.

@ddsjoberg ddsjoberg mentioned this issue May 4, 2021
14 tasks
ddsjoberg added a commit that referenced this issue May 4, 2021
* assigning all variables a test (even when all values are NA)

* increment version number
@ddsjoberg
Copy link
Owner

Thank you so much for the repot @fh-jsnider !

I've added a fix to the dev version. If you'd like to continue using the CRAN release, you'll just need to assign a test to the variable with all missing variables. The issue arose when the missing column was not assigned a default test.

@fh-jsnider
Copy link
Author

fh-jsnider commented May 5, 2021

Thanks so much! Appreciate the speedy work :)

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