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

Bug: derive_summary_records requires by_vars in dataset #2686

Open
bundfussr opened this issue Mar 14, 2025 · 0 comments
Open

Bug: derive_summary_records requires by_vars in dataset #2686

bundfussr opened this issue Mar 14, 2025 · 0 comments
Labels
bug Something isn't working programming

Comments

@bundfussr
Copy link
Collaborator

What happened?

The checks in derive_summary_records() are too restrictive: by_vars are expected in dataset although the code doesn't require it.

Session Information

No response

Reproducible Example

library(dplyr)
adbs <- tribble(
  ~AVISITN, ~ADY,  ~AVAL,
  1,           1,  10,
  2,           8,  12,
  3,          15,  10,
  3,          17,  14
) %>%
  mutate(USUBJID = "1")

derive_summary_records(
  dataset_add = adbs,
  by_vars = exprs(USUBJID),
  set_values_to = exprs(
    AVAL = mean(AVAL),
    PARAMCD = "MEANALL"
  )
) %>%
  derive_summary_records(
    dataset_add = adbs,
    by_vars = exprs(USUBJID, AVISITN),
    set_values_to = exprs(
      AVAL = mean(AVAL),
      PARAMCD = "MEANVISIT"
    )
  )

produces

Error in `derive_summary_records()`:
! Required variable `AVISITN` is missing in `dataset`
Run `rlang::last_trace()` to see where the error occurred.

It shouldn't fail but result in

# A tibble: 4 × 4
  USUBJID  AVAL PARAMCD   AVISITN
  <chr>   <dbl> <chr>       <dbl>
1 1        11.5 MEANALL        NA
2 1        10   MEANVISIT       1
3 1        12   MEANVISIT       2
4 1        12   MEANVISIT       3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working programming
Development

No branches or pull requests

1 participant