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

tbl_uvregression() to accept survey objects #740

Merged
merged 7 commits into from
Jan 16, 2021
Merged

Conversation

ddsjoberg
Copy link
Owner

@ddsjoberg ddsjoberg commented Jan 12, 2021

What changes are proposed in this pull request?

tt <- survey::svydesign(~1, data = as.data.frame(Titanic), weights = ~Freq) 

tbl <- 
  tt %>%
  tbl_uvregression(
    y = Survived,
    method = survey::svyglm,
    method.args = list(family = binomial),
    hide_n = TRUE
  )
tbl

image


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
  • usethis::use_spell_check() runs with no spelling errors in documentation

When the branch is ready to be merged into master:

  • Update NEWS.md 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).
  • Increment the version number using usethis::use_version(which = "dev")
  • Run codemetar::write_codemeta()
  • Run usethis::use_spell_check() again
  • Approve Pull Request
  • Merge the PR. Please use "Squash and merge".

@ddsjoberg
Copy link
Owner Author

@larmarange would you mind reviewing this pull request please? Anytime we're working with survey objects, I feel somewhat nervous! Thank you!

@@ -25,6 +25,7 @@
#'
#' @param data Data frame to be used in univariate regression modeling. Data
#' frame includes the outcome variable(s) and the independent variables.
#' Survey design is also accepted.
#' @param method Regression method (e.g. [lm], [glm], [survival::coxph], and more).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add [survey::svyglm] in the list of possibilities ?

Copy link
Collaborator

@larmarange larmarange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it looks OK. However, as is, it appears to be a hidden feature. I would simply update documentation. (cf comments)

Otherwise, this is great!!! :-)

@@ -106,6 +107,12 @@ tbl_uvregression <- function(data, method, y = NULL, x = NULL, method.args = NUL
)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a third example in the examples using a survey object

@ddsjoberg
Copy link
Owner Author

@larmarange thank you so so so much!

@ddsjoberg ddsjoberg merged commit d85aff2 into master Jan 16, 2021
@ddsjoberg ddsjoberg deleted the uvreg_for_survey branch January 16, 2021 00:19
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 this pull request may close these issues.

Add support for survey objects with tbl_uvregression()
2 participants