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

Handling for when scr_unit is missing-y #64

Merged
merged 2 commits into from
Oct 18, 2024
Merged

Conversation

jasmineirx
Copy link
Contributor

@jasmineirx jasmineirx commented Oct 17, 2024

In the change I made in #63, convert_creat_unit would error if scr_unit was a vector of length 0:

Error in match.arg(unit_in, several.ok = TRUE) :
'arg' must be of length >= 1

This PR adds additional error handling, falling back to the same default as a NULL scr_unit in the case of a vector of length 0 or where all supplied values are NA.

Copy link
Contributor

@roninsightrx roninsightrx left a comment

Choose a reason for hiding this comment

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

ok

@@ -146,7 +146,7 @@ calc_egfr <- function (
}

# ---- Convert Creatinine
if (is.null(scr_unit)) {
if (is.null(scr_unit) || length(scr_unit) == 0 || all(is.na(scr_unit))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

is scr_unit a vector? is.null(scr_unit) would be FALSE if scr_unit = c(NULL, "mg/dL")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

true, but it would be caught in the next line and return an error about unrecognized units, which seems okay

@jasmineirx jasmineirx merged commit b81e0ee into master Oct 18, 2024
1 check passed
@jasmineirx jasmineirx deleted the scr_unit_handling branch October 18, 2024 14:33
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.

3 participants