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

Added add_ess_header() function #12

Merged
merged 16 commits into from
Feb 3, 2025

Conversation

ddsjoberg
Copy link
Contributor

@ddsjoberg ddsjoberg commented Feb 2, 2025

PR adds the basics of what you'll need to replace the default headers in tbl_svysummary() with ESS-calculated numbers.

This does add new dependencies, some of which you could do a little re-writing to remove.
FYI to run the examples in the help file, the user needs survey, gtsummary, cards, and cardx packages, which is why all of them have been added to suggests. I used gtsummary::trial data set in the examples, but I am sure you have a more suitable example on hand, so feel free to update.

The function still needs unit tests, but I thought you could write them after you confirm I didn't implement the ESS calculation incorrectly 😜

I also ran usethis::use_github_action("test-coverage.yaml") because the v3 of the artifact upload workflow is now deprecated.

closes #11

@malcolmbarrett
Copy link
Collaborator

Thanks, @ddsjoberg! I added some tests and tweaked the docs a bit.

One thing I changed was to label it as ESS. Is there a good way to make an automatic footnote to explain the acronym?

R/add_ess_header.R Outdated Show resolved Hide resolved
@ddsjoberg
Copy link
Contributor Author

ddsjoberg commented Feb 3, 2025

One thing I changed was to label it as ESS. Is there a good way to make an automatic footnote to explain the acronym?

Yes! In the next release (hoping to go to CRAN in the next 3 weeks or so), there is a new function just for abbreviations.

svy <- survey::svydesign(~1, data = nhefs_weights, weights = ~ w_ate)
gtsummary::tbl_svysummary(svy, include = c(age, sex, smokeyrs)) |>
  add_ess_header() |> 
  gtsummary::modify_abbreviation("ESS = Effective Sample Size")

image

We could add a line at the end of the add_ess_header() function like this:

if (grepl(pattern = "ESS", x = header, fixed = TRUE)) {
  x <- gtsummary::modify_abbreviation(x, "ESS = Effective Sample Size")
}

@ddsjoberg
Copy link
Contributor Author

Ahhh, lewking cute!

image

@malcolmbarrett
Copy link
Collaborator

Yaaa! Almost there, just fixing some R CMD Check issues.

Incidentally, I have warnPartialMatchArgs = TRUE turned on, and I see:

Warning messages:
1: In cards::nest_for_ard(data$variables, by = by, key = "...ard_no_one_will_ever_pick_this...",  :
  partial argument match of 'rename' to 'rename_columns'

I don't think this stems from this change so I thought I'd point it out to you

@malcolmbarrett
Copy link
Collaborator

Thanks a million, @ddsjoberg! This is awesome

@malcolmbarrett malcolmbarrett merged commit 634a0d6 into r-causal:main Feb 3, 2025
7 checks passed
@ddsjoberg
Copy link
Contributor Author

Ah, yes, thanks for pointing out the partial match. I'll update (someday...)

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.

Implement add_ess_header()
2 participants