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

Feature request: tbl_summary() analyze only non-missing values in "split by" operations #1599

Closed
ledermanr opened this issue Feb 6, 2024 · 1 comment

Comments

@ledermanr
Copy link

In tbl_summary(by = trt)

it would be extremely helpful to provide an option to confined analyses to non-missing values, by variable.

For example
A with n=60 subjects at timepoint=baseline, n=45 subjects at timepoint=day30, and n=30 subjects at timepoint=day60 may have inconsistently missing values for variables such as mr_severity, mitral_gradient, lvot_diameter across timepoints.

A classic shortcoming of medical literature is that mean/median values for observations tbl_summary(by=timepoint) that are depicted in tabular form, created using tools such as tbl_summary, without accounting for missing values. Yes I know I could filter the data piped into tbl_summary, but that is difficult for a civilian like me.

Thank you for considering this feature request and for this fabulous toolkit!

@ddsjoberg
Copy link
Owner

hi @ledermanr , thanks for the post!!

I certainly understand where you're coming from. The tbl_summary() tool is quite general for many more cases than baseline and followup visits, which would make this operation difficult to generalize (e.g. tbl_summary() doesn't even know the subject ID). Unfortunately, I don't think this is a feature we can implement.

If it helps, this code can quickly remove subjects without full followup. Image each subject is meant to have 2 rows in the data: baseline and followup.

df |>
  # remove subjects without both baseline and followup visits 
  dplyr::filter(
    .by = SUBJECTID,
    dplyr::n() == 2
  )

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