-
Notifications
You must be signed in to change notification settings - Fork 36
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
Refactor dropped non-numeric columns with recover #1193
Conversation
new_col_set <- dimnames(dm)[[2]] | ||
old_col_set <- names(x) | ||
drop <- old_col_set[!old_col_set %in% new_col_set] | ||
drop <- drop[drop %in% check] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this logic for clarity.
old_col_set <- names(x) | ||
drop <- old_col_set[!old_col_set %in% new_col_set] | ||
drop <- drop[drop %in% check] | ||
if(!length(drop)) return(invisible(NULL)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to explicitly exit now that errors are generated; I think before, there might have been nothing in drop
but we kept going and no one knew.
##' @param verbose logical. | ||
##' @param quiet if `TRUE`, messages will be suppressed. | ||
##' | ||
##' @details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mostly called under the hood; but I filled out details since we're referencing the function name in the error message and probably good to get more of this written down somewhere.
##' An error will be issued when | ||
##' - non-numeric data is found in columns sharing names with model parameters | ||
##' - non-numeric data is found in reserved data items related to dosing | ||
##' (see `mrgsolve:::GLOBALS$CARRY_TRAN`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is referencing this internal GLOBALS
data structure a bad idea? I don't want to have to maintain this list off the contents of what is in there but also feels odd to expose this internal data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion it's okay to reference. It's useful to those that want to see the list, but it being internal should make it clear that it shouldn't be relied on in scripts, etc.
@@ -582,6 +582,8 @@ do_mrgsim <- function(x, | |||
data$.data_row. <- join_data$.data_row. | |||
carry.recover <- ".data_row." | |||
drop <- names(which(!is.numeric(join_data))) | |||
# Will be dropped with error later when validating data | |||
drop <- drop[!drop %in% c(Pars(x), c(Pars(m), GLOBALS$CARRY_TRAN)] | |||
data <- data[,setdiff(names(data),drop),drop=FALSE] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly can't remember why we're dropping data columns here when it will happen later. For now, will keep it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left one comment about adjacent doc typo
##' An error will be issued when | ||
##' - non-numeric data is found in columns sharing names with model parameters | ||
##' - non-numeric data is found in reserved data items related to dosing | ||
##' (see `mrgsolve:::GLOBALS$CARRY_TRAN`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion it's okay to reference. It's useful to those that want to see the list, but it being internal should make it clear that it shouldn't be relied on in scripts, etc.
Summary
See #1184
recover
handling inmrgsim()
to defer errors for non-numeric columns that are also parameters; this lets the validate data set functions issue the errorCreated on 2024-05-21 with reprex v2.0.2