Skip to content

Commit

Permalink
Account for floating point imprecisions in sofa_cardio
Browse files Browse the repository at this point in the history
  • Loading branch information
prockenschaub committed Apr 11, 2024
1 parent 7f2cc42 commit 7e8d781
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions R/callback-sofa.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,13 @@ sofa_liver <- sofa_single(
sofa_cardio <- function(..., interval = NULL) {

score_calc <- function(map, dopa, norepi, dobu, epi) {
eps <- .Machine$double.eps ^ 0.5
fifelse(
is_true(dopa > 15 | epi > 0.1 | norepi > 0.1), 4L, fifelse(
is_true(dopa > 5 | (epi > 0 & epi <= 0.1) |
(norepi > 0 & norepi <= 0.1)), 3L, fifelse(
is_true((dopa > 0 & dopa <= 5) | dobu > 0), 2L, fifelse(
is_true(map < 70), 1L, 0L
is_true(dopa > 15 + eps | epi > 0.1 + eps | norepi > 0.1 + eps), 4L, fifelse(
is_true(dopa > 5 + eps | (epi > 0 + eps & epi <= 0.1 + eps) |
(norepi > 0 + eps & norepi <= 0.1 + eps)), 3L, fifelse(
is_true((dopa > 0 + eps & dopa <= 5 + eps) | dobu > 0 + eps), 2L, fifelse(
is_true(map < 70), 1L, 0L
)
)
)
Expand Down

0 comments on commit 7e8d781

Please sign in to comment.