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

Is there a way to combine multiple 1-way tabyls together? #387

Closed
ksw9 opened this issue Jul 8, 2020 · 3 comments
Closed

Is there a way to combine multiple 1-way tabyls together? #387

ksw9 opened this issue Jul 8, 2020 · 3 comments

Comments

@ksw9
Copy link

ksw9 commented Jul 8, 2020

Thanks for a great package. I was wondering if there is a way to combine multiple 1-way tabyls together for formatting? For example, I'd like to summarize patient population characteristics in a single table.

Thank you!

@sfirke
Copy link
Owner

sfirke commented Jul 8, 2020

Thanks for the note! Could you say more about this use case, maybe showing an example of what the final combined table would look like?

@ksw9
Copy link
Author

ksw9 commented Jul 8, 2020

Thanks!
For example, it would be great to be able to combine the following tabyls, s1 and s4, with several others into a large dataframe that preserves the formatting across variables of different types so that I can export an image, with grid.table (or something else). Is there a straightforward way to do this? Thank you!

s1 <- pop_sub %>%
tabyl(sex) %>%
adorn_pct_formatting()
s1

sex  n percent
   F 46   31.7%
   M 99   68.3%

s4 <- pop_sub %>%
tabyl(binned_age) %>%
adorn_pct_formatting()
s4

 binned_age  n percent
       < 18  8    5.5%
      18-25 24   16.6%
      26-35 38   26.2%
      36-55 53   36.6%
      55-70 21   14.5%
       > 70  1    0.7%

@sfirke
Copy link
Owner

sfirke commented Dec 9, 2021

Sorry not to respond here. If this is still relevant, can you open a Discussion thread? https://github.com/sfirke/janitor/discussions I'm closing it here since I don't think it needs anything on the software development front. If you'd want to combine those vertically, I'd suggest using dplyr::bind_rows and moving the first column name into a "variable" column.

@sfirke sfirke closed this as completed Dec 9, 2021
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

No branches or pull requests

2 participants