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

allowing for any class to be passed to tbl_summary #603

Closed
wants to merge 39 commits into from

Conversation

ddsjoberg
Copy link
Owner

@ddsjoberg ddsjoberg commented Aug 2, 2020

What changes are proposed in this pull request?
This PR allows columns of any class to be summarized by tbl_summary().

Outstanding items:

  • Do more testing with dates, times, datetimes, and lubridates (including quarters within lunbridate)
  • Can we improve error messaging if users sends column so a summary function that cannot handle it?
  • Still need to remove custom ordered factors code.
  • You can pass dates now, but there is no way to format them 🤷
  • We open ourselves up to a whole new set of errors that are difficult to anticipate by accepting a column of any class.
    • We need to add more informative error messaging, but that is actually hard to do.
    • We could add a column to .$meta_data indicating if the column is a base R type/class. When there are errors with non-base types, we could pass a special error message.

Haven labelled example

tibble::tibble(
  s1 = haven::labelled(c("M", "M", "F"), c(Male = "M", Female = "F")), 
  s2 = haven::labelled(c(1, 1, 2), c(Male = 1, Female = 2)), 
  s3 = haven::labelled(c(1, 1, 2), c(Male = 1, Female = 2),
                       label="Assigned sex at birth")
) %>%
  tbl_summary(
    type = list(c(s2, s3) ~ "continuous")
  )

If there is an GitHub issue associated with this pull request, please provide link.

closes #569
closes #488
closes #540


Checklist for PR reviewer

  • PR branch has pulled the most recent updates from master branch. Ensure the pull request branch and your local version match and both have the latest updates from the master branch.
  • If an update was made to tbl_summary(), was the same change implemented for tbl_svysummary()?
  • If a new function was added, function included in _pkgdown.yml
  • If a bug was fixed, a unit test was added for the bug check
  • Run pkgdown::build_site(). Check the R console for errors, and review the rendered website.
  • Code coverage is suitable for any new functions/features. Review coverage with covr::report(). Before you run, set Sys.setenv(NOT_CRAN = TRUE) and begin in a fresh R session without any packages loaded.
  • R CMD Check runs without errors, warnings, and notes
  • NEWS.md has been updated with the changes from this pull request under the heading "# gtsummary (development version)". If there is an issue associated with the pull request, reference it in parantheses at the end update (see NEWS.md for examples).
  • usethis::use_spell_check() runs with no spelling errors in documentation
  • When the branch is ready to be merged into master, increment the version number using usethis::use_version(which = "dev"), run codemetar::write_codemeta(), approve, and merge the PR.

@ddsjoberg ddsjoberg marked this pull request as ready for review August 14, 2020 01:03
@ddsjoberg
Copy link
Owner Author

@karissawhiting this is not pressing in any way. But when you have a chance can you begin testing and give feedback?

@ddsjoberg
Copy link
Owner Author

/document

@ddsjoberg ddsjoberg marked this pull request as draft January 11, 2021 21:00
@ddsjoberg
Copy link
Owner Author

closing in favor of PR #794

@ddsjoberg ddsjoberg closed this Feb 23, 2021
@ddsjoberg ddsjoberg deleted the accept_all_classes branch March 19, 2021 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment