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

Function trunc_time does not actually truncate #52

Open
prockenschaub opened this issue Mar 15, 2024 · 0 comments
Open

Function trunc_time does not actually truncate #52

prockenschaub opened this issue Mar 15, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@prockenschaub
Copy link
Collaborator

The function create_intervals inside expand_intervals used by mimic_rate_cv calls the function trunc_time in order to truncate times after 6 hours. There are two issues here:

  1. I am unsure whether a hard-coded truncation after 6 hours is sensible for a function that isn't MIMIC-specific. There might be something I am missing here but I think it would make sense to have expand_intervals take a max_len argument that then defaults to 6 hours.

ricu/R/callback-itm.R

Lines 414 to 415 in 7f2cc42

x <- create_intervals(x, c(id_vars(x), grp_var), overhang = hours(1L),
max_len = hours(6L), end_var = "endtime")

  1. The above is currently moot in any case, as trunc_time currently doesn't actually truncate. The replace function is currently never assigned back to the vector x.

ricu/R/utils-ts.R

Lines 643 to 654 in 7f2cc42

trunc_time <- function(x, min, max) {
if (not_null(min)) {
replace(x, x < min, min)
}
if (not_null(max)) {
replace(x, x > max, max)
}
x
}

This can be easily checked by running

debugonce(trunc_time)
load_concepts("norepi_rate", "mimic_demo")

which has a max length of 14 even after "truncating".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant