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

Add test case for baseline_timepoints in derive_blfl function #95

Merged
merged 5 commits into from
Sep 12, 2024

Conversation

ShiyuC
Copy link
Collaborator

@ShiyuC ShiyuC commented Aug 29, 2024

This PR touches #59, bullet point 3.

  • Modify the test case to cover the usage of baseline_timepoints.
  • Add different examples for the function

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 devel branch until you have checked off each task.

  • Place Closes #<insert_issue_number> into the beginning of your Pull z
    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?
  • 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 if the changes pertain to a user-facing function (i.e. it
    has an @export tag) or documentation aimed at users (rather than developers)
  • Build oak 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!

@ShiyuC ShiyuC linked an issue Aug 29, 2024 that may be closed by this pull request
Copy link

github-actions bot commented Aug 29, 2024

Code Coverage

Package Line Rate Health
sdtm.oak 93%
Summary 93% (952 / 1019)

@ShiyuC
Copy link
Collaborator Author

ShiyuC commented Sep 6, 2024

@edgar-manukyan @ramiromagno May I request your review of this small MR? Thanks in advance

Copy link
Collaborator

@ramiromagno ramiromagno left a comment

Choose a reason for hiding this comment

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

Hi @ShiyuC:

When it comes to this PR specifically, I think that the changes are working as expected.

I took a look at the function code itself and there are a few things I personally think should be improved (but this might be addressed on a separate issue or not... I leave it up to you, Edgar and Ramm to decide)

  • ISO 8601 formatted dates are being used as character and not as date-times on their own right. This means that date and time comparisons are being done lexicographically, which I find dangerous (even though I understand the measures taken at dtc_datepart() and dtc_timepart() to make sure the format is comparable).
  • Using dplyr verbs (dplyr::mutate(), dplyr::na_if(), tidyr::drop_na()) to make code more readable here:
      bad_orres_rows <- is.na(ds_mod[[domain_prefixed_names["orres"]]]) |
      trimws(ds_mod[[domain_prefixed_names["orres"]]]) %in% c("ND", "NOT DONE", "")
      ds_mod <- ds_mod[!bad_orres_rows, ]
  • I think there is a bug in line 355, var_tpt -> tpt
    con_col <- c(domain_prefixed_names[c("testcd", "dtc", "var_tpt")], "VISIT")
  • Not that I think it makes a difference in the resulting computations, but it would be more human-readable, I would change sdtm_in to ds_mod:
       con_col <- con_col[con_col %in% names(sdtm_in)]
  • Is the setting of <unspecified> something that is part of the SDTM standard?
  • Replace rbind() with dplyr's equivalent
  • Replace dplyr::arrange_at() with arrange() as the former is superseded.
  • Replace the pattern get(domain_prefixed_names["tpt"]) by idiomatic rlang alternatives, e.g. !!rlang::sym(...) or {{...}}.

@edgar-manukyan
Copy link
Collaborator

Thanks team. Shall we add a new issue with Ramiro's nice findings/suggestions and refactor the derive_blfl in that issue?

@ShiyuC
Copy link
Collaborator Author

ShiyuC commented Sep 11, 2024

Hi @ShiyuC:

When it comes to this PR specifically, I think that the changes are working as expected.

I took a look at the function code itself and there are a few things I personally think should be improved (but this might be addressed on a separate issue or not... I leave it up to you, Edgar and Ramm to decide)

  • ISO 8601 formatted dates are being used as character and not as date-times on their own right. This means that date and time comparisons are being done lexicographically, which I find dangerous (even though I understand the measures taken at dtc_datepart() and dtc_timepart() to make sure the format is comparable).
  • Using dplyr verbs (dplyr::mutate(), dplyr::na_if(), tidyr::drop_na()) to make code more readable here:
      bad_orres_rows <- is.na(ds_mod[[domain_prefixed_names["orres"]]]) |
      trimws(ds_mod[[domain_prefixed_names["orres"]]]) %in% c("ND", "NOT DONE", "")
      ds_mod <- ds_mod[!bad_orres_rows, ]
  • I think there is a bug in line 355, var_tpt -> tpt
    con_col <- c(domain_prefixed_names[c("testcd", "dtc", "var_tpt")], "VISIT")
  • Not that I think it makes a difference in the resulting computations, but it would be more human-readable, I would change sdtm_in to ds_mod:
       con_col <- con_col[con_col %in% names(sdtm_in)]
  • Is the setting of <unspecified> something that is part of the SDTM standard?
  • Replace rbind() with dplyr's equivalent
  • Replace dplyr::arrange_at() with arrange() as the former is superseded.
  • Replace the pattern get(domain_prefixed_names["tpt"]) by idiomatic rlang alternatives, e.g. !!rlang::sym(...) or {{...}}.

We can probably add these comments to issue #59

@ShiyuC
Copy link
Collaborator Author

ShiyuC commented Sep 11, 2024

Ram's comment: add example for baseline_timepoints

ShiyuC and others added 3 commits September 11, 2024 20:45
Merge remote-tracking branch 'origin/main' into 59-tmpt-test
# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
@ShiyuC ShiyuC merged commit 31aadcd into main Sep 12, 2024
14 checks passed
@ShiyuC ShiyuC deleted the 59-tmpt-test branch September 12, 2024 22:40
@ShiyuC ShiyuC mentioned this pull request Sep 23, 2024
14 tasks
@ShiyuC
Copy link
Collaborator Author

ShiyuC commented Sep 25, 2024

  • ISO 8601 formatted dates are being used as character and not as date-times on their own right. This means that date and time comparisons are being done lexicographically, which I find dangerous (even though I understand the measures taken at dtc_datepart() and dtc_timepart() to make sure the format is comparable).
    Confirmed that ISO 8601 will be applied to date time variables before blfl derivation, so comparing in lexicographic order should be fine. I will add code in there to check the format and give message
  • Is the setting of something that is part of the SDTM standard?
    This is not SDTM standard, but we fill in the value to make sure VISIT does not have blank values.

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

Successfully merging this pull request may close these issues.

derive_blfl - Address review comments
4 participants