Skip to content

Closes #3014: Bug fix: derive_vars_dt() rejects user-defined date_imputation with highest_imputation = "D" [create website]#3134

Merged
manciniedoardo merged 23 commits into
mainfrom
3014_derive_vars_dt_user_defined_date_imp_with_d
Jun 9, 2026
Merged

Closes #3014: Bug fix: derive_vars_dt() rejects user-defined date_imputation with highest_imputation = "D" [create website]#3134
manciniedoardo merged 23 commits into
mainfrom
3014_derive_vars_dt_user_defined_date_imp_with_d

Conversation

@manciniedoardo

@manciniedoardo manciniedoardo commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Thank you for your Pull Request! We have developed this task checklist from the Development Process Guide to help with the final steps of the process. Completing the below tasks helps to ensure our reviewers can maximize their time on your code as well as making sure the admiral codebase remains robust and consistent.

Please check off each taskbox as an acknowledgment that you completed the task or check off that it is not relevant to your Pull Request. This checklist is part of the Github Action workflows and the Pull Request will not be merged into the main branch until you have checked off each task.

  • Place Closes #<insert_issue_number> into the beginning of your Pull Request Title (Use Edit button in top-right if you need to update)
  • Code is formatted according to the tidyverse style guide. Run styler::style_file() to style R and Rmd files
  • Updated relevant unit tests or have written new unit tests, which should consider realistic data scenarios and edge cases, e.g. empty datasets, errors, boundary cases etc. - See Unit Test Guide
  • If you removed/replaced any function and/or function parameters, did you fully follow the deprecation guidance?
  • Review the Cheat Sheet. Make any required updates to it by editing the file inst/cheatsheet/admiral_cheatsheet.pptx and re-upload a PDF and a PNG version of it to the same folder. (The PNG version can be created by taking a screenshot of the PDF version.)
  • Update to all relevant roxygen headers and examples, including keywords and families. Refer to the categorization of functions to tag appropriate keyword/family.
  • Run devtools::document() so all .Rd files in the man folder and the NAMESPACE file in the project root are updated appropriately
  • Address any updates needed for vignettes and/or templates
  • Update NEWS.md under the header # admiral (development version) if the changes pertain to a user-facing function (i.e. it has an @export tag) or documentation aimed at users (rather than developers). A Developer Notes section is available in NEWS.md for tracking developer-facing issues.
  • Build admiral site pkgdown::build_site() and check that all affected examples are displayed correctly and that all new functions occur on the "Reference" page.
  • Address or fix all lintr warnings and errors - lintr::lint_package()
  • Run R CMD check locally and address all errors and warnings - devtools::check()
  • Link the issue in the Development Section on the right hand side.
  • Address all merge conflicts and resolve appropriately
  • Pat yourself on the back for a job well done! Much love to your accomplishment!

To create the website for the content of this PR add "[create website]" to the title of the pull request.

@manciniedoardo manciniedoardo changed the title Closes #3014: Bug fix: derive_vars_dt() rejects user-defined date_imputation with highest_imputation = "D" Closes #3014: Bug fix: derive_vars_dt() rejects user-defined date_imputation with highest_imputation = "D" [create website] Jun 3, 2026
@manciniedoardo manciniedoardo requested review from a team and bundfussr June 3, 2026 07:51
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Code Coverage

Package Line Rate Health
admiral 100%
Summary 100% (6237 / 6243)

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

The website/documentation is available at https://pharmaverse.github.io/admiral/3014_derive_vars_dt_user_defined_date_imp_with_d.

Comment thread man/derive_vars_dt.Rd Outdated
Comment thread R/derive_vars_dt.R
Comment thread R/derive_vars_dt_dtm_utils.R Outdated
Comment thread R/derive_vars_dt_dtm_utils.R Outdated
Comment thread NEWS.md Outdated
Comment thread vignettes/imputation.Rmd Outdated
manciniedoardo and others added 2 commits June 3, 2026 11:40
Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>
@manciniedoardo manciniedoardo requested a review from bundfussr June 3, 2026 11:01
Comment thread man/roxygen/rdx_meta.R Outdated
Comment thread R/derive_vars_dt.R Outdated
@manciniedoardo manciniedoardo requested a review from bundfussr June 3, 2026 12:37
Comment thread R/derive_vars_dt.R
Comment thread R/derive_vars_dt.R Outdated
#' middle of the possible range:
#' - The`"first"` and `"last"` keywords allow imputation to the first/last
#' day/month. They can also be used to impute the year if used in conjunction
#' with the `min_dates` or `max_dates` arguments (see examples).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to hyperlink to the examples?

Suggested change
#' with the `min_dates` or `max_dates` arguments (see examples).
#' with the `min_dates` or `max_dates` arguments [(see examples)](link??).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@manciniedoardo add me to slack please

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this is a good idea - the argument is inherited by other functions.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the examples in the docs using min/max args

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

Comment thread R/derive_vars_dt.R Outdated
Comment thread R/derive_vars_dt.R Outdated
Comment on lines +641 to +644
"{.arg date_imputation} is set to {.val {date_imputation}}.",
"Are you sure that with this value you are generating all valid dates?",
"E.g. {.code date_imputation = 31} would impute \"2020-02\" to \"2020-02-31\",",
"which is invalid."

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just catching up here - this is going to fall over if the date is invalid no matter what?? - Should we just say this imputation produces invalid dates and should be reviewed and corrected??.

The phrase: Are you sure that with this value you are generating all valid dates? implies that this can be circumvented?? but i might be off here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair point, let me update the message.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually the message is in admiraldev... :( would have to update it there. but to be fair, it will fall over (error) so you will need to go in and update anyhow? or am i being lazy??

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turns out I hallucinated - I an definitely edit this text and have improved the error message to print out some of the problem dates.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Comment thread R/derive_vars_dt_dtm_utils.R
@manciniedoardo manciniedoardo requested a review from bms63 June 8, 2026 07:58
Comment thread R/derive_vars_dt.R Outdated
Comment thread R/derive_vars_dt.R Outdated
Comment thread R/derive_vars_dt.R Outdated
manciniedoardo and others added 4 commits June 8, 2026 10:35
Co-authored-by: Stefan Bundfuss <80953585+bundfussr@users.noreply.github.com>
…thub.com:pharmaverse/admiral into 3014_derive_vars_dt_user_defined_date_imp_with_d
@manciniedoardo manciniedoardo requested a review from bundfussr June 8, 2026 09:39
Comment thread R/derive_vars_dt.R Outdated
Comment thread R/derive_vars_dt.R Outdated
@manciniedoardo manciniedoardo merged commit 25bd6ff into main Jun 9, 2026
18 checks passed
@manciniedoardo manciniedoardo deleted the 3014_derive_vars_dt_user_defined_date_imp_with_d branch June 9, 2026 09:44
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.

Bug: derive_vars_dt() rejects user-defined date_imputation with highest_imputation = "D"

3 participants