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

Improve error messaging for derive_param_tte() #2519

Closed
rossfarrugia opened this issue Oct 2, 2024 · 5 comments · Fixed by #2530
Closed

Improve error messaging for derive_param_tte() #2519

rossfarrugia opened this issue Oct 2, 2024 · 5 comments · Fixed by #2530
Assignees

Comments

@rossfarrugia
Copy link
Collaborator

rossfarrugia commented Oct 2, 2024

What happened?

Any reason why derive_param_tte() argument source_datasets doesn't like underscores?

Session Information

Using {admiral} 1.1.1

Reproducible Example

This code works (assuming I have a valid adsl_death dataset and I've set rand_censor):

death <- event_source(
  dataset_name = "adsl",
  filter = DTHFL == "Y",
  date = DTHDT
)

test_os <- derive_param_tte(
  dataset_adsl = adsl_death,
  start_date = RANDDT,
  event_conditions = list(death),
  censor_conditions = list(rand_censor),
  source_datasets = list(adsl = adsl_death),
  set_values_to = exprs(
    PARAMCD = "OS"
  )
)

This code errors:

death <- event_source(
  dataset_name = "adsl_death",
  filter = DTHFL == "Y",
  date = DTHDT
)

test_os <- derive_param_tte(
  dataset_adsl = adsl_death,
  start_date = RANDDT,
  event_conditions = list(death),
  censor_conditions = list(rand_censor),
  source_datasets = list(adsl_death = adsl_death),
  set_values_to = exprs(
    PARAMCD = "OS"
  )
)

The error given is:

Error in `fun(..., .envir = .envir)`:
! Could not evaluate cli `{}` expression: `source_names`.
Caused by error in `eval(expr, envir = envir)`:
! object 'source_names' not found
Type .Last.error to see the more details.
@bundfussr
Copy link
Collaborator

@rossfarrugia , I think the issue is not related to underscores but an issue in the error message. The correct error message should be:

Error in `derive_param_tte()`:
! The dataset names must be included in the list specified for the `source_datasets` argument.
ℹ Following names were provided by `source_datasets`: "adsl_death"
ℹ But, `censor_conditions[[1]]$dataset_name = adsl`

I assume in your example rand_censor is referring to adsl instead of adsl_death. Could you check?

@rossfarrugia
Copy link
Collaborator Author

Yes! That's it @bundfussr - great spot. It was an error on my side but the error message could definitely be improved, as I'd have spent hours trying to figure that out.

@rossfarrugia rossfarrugia changed the title Bug: Any reason why derive_param_tte() argument source_datasets doesn't like underscores Improve error messaging for derive_param_tte() Oct 11, 2024
@rossfarrugia rossfarrugia removed the bug Something isn't working label Oct 11, 2024
@bundfussr
Copy link
Collaborator

Yes! That's it @bundfussr - great spot. It was an error on my side but the error message could definitely be improved, as I'd have spent hours trying to figure that out.

@rossfarrugia , I have fixed the bug in the error message. If you want to try it out, you need to call remotes::install_github("pharmaverse/admiraldev", ref = "469_fix_assert_list_element") to install the admiraldev version where the bug is fixed.

@rossfarrugia
Copy link
Collaborator Author

yes, works now by giving better error message when re-running the same code 👍

@bms63
Copy link
Collaborator

bms63 commented Oct 11, 2024

Yes! That's it @bundfussr - great spot. It was an error on my side but the error message could definitely be improved, as I'd have spent hours trying to figure that out.

hours!! oh no!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

3 participants