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: assert_data_frame() doesn't check if it is a rowwise dataframe #475

Open
bundfussr opened this issue Dec 4, 2024 · 0 comments
Open
Labels
bug Something isn't working good first issue Good for newcomers programming

Comments

@bundfussr
Copy link
Collaborator

What happened?

The assert_data_frame() function doesn't check if it is a rowwise dataframe. This can cause failure or unexpected behaviour of admiral functions (see example from the "Visit and Period Variables" vignette below).

Session Information

No response

Reproducible Example

windows <- tribble(
  ~AVISIT,    ~AWLO, ~AWHI, ~AVISITN, ~AWTARGET,
  "BASELINE",   -30,     1,        0,         1,
  "WEEK 1",       2,     7,        1,         5,
  "WEEK 2",       8,    15,        2,        11,
  "WEEK 3",      16,    22,        3,        19,
  "WEEK 4",      23,    30,        4,        26
)

adbds <- tribble(
  ~USUBJID, ~ADY,
  "1",       -33,
  "1",        -2,
  "1",         3,
  "1",        24,
  "2",        NA,
) %>% rowwise()

adbds1 <- adbds %>%
  derive_vars_joined(
    dataset_add = windows,
    filter_join = AWLO <= ADY & ADY <= AWHI,
    join_type = "all",
  )

produces

Error in `signal_duplicate_records()` at admiral/R/derive_merged.R:379:5:
! After applying `filter_join` the joined dataset contains more than one observation per observation of the input
  dataset. Please adjust `filter_add` and/or `filter_join` or specify `order` and `mode` to select one of the observations.
ℹ Run admiral::get_duplicates_dataset() to access the duplicate records
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers programming
Development

No branches or pull requests

1 participant