Skip to content

Commit

Permalink
fix: handle errorneous measurements
Browse files Browse the repository at this point in the history
  • Loading branch information
sgibb committed Jun 10, 2024
1 parent 710b7bf commit c73a3dd
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: dltr
Title: Draeger logbook and trend reader
Version: 0.0.2.9000
Version: 0.0.3
Authors@R:
person(
given = "Sebastian", family = "Gibb",
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Changes in development version

## Changes in 0.0.3

- Fix `.melt_measurements` for erroneous values ("ERR" or "+++").

## Changes in 0.0.2

- Export `add_anesthesia_case_id`.
Expand Down
6 changes: 5 additions & 1 deletion R/read_logbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ add_anaesthesia_case_id <- function(x) {
measure.vars <- colnames(x)[
grepl("^etCO2|^MV|^Pmean|^PIP|^PP|^PEEP|^FiO|^prim.", colnames(x))
]
x[, (measure.vars) := lapply(.SD, as.double), .SDcols = measure.vars]
x[,
(measure.vars) :=
lapply(.SD, function(x)as.double(sub("ERR|\\+\\+\\+", "", x))),
.SDcols = measure.vars
]
m <- melt(
x[Label == "Measurements", c("DateTime", measure.vars), with = FALSE],
id.vars = "DateTime",
Expand Down
4 changes: 2 additions & 2 deletions tests/testthat/test_read_logbook.R
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ test_that(".melt_measurements", {
c(rep("2024-06-04 12:45", 3), "2024-06-04 13:00")
),
Label = c("Measurements", "foo", "bar", "Measurements"),
`etCO2 [mmHg]` = c(35, NA, NA, 37),
`MV [l/min]` = c(5.0, NA, NA, 4.8)
`etCO2 [mmHg]` = c(35, "ERR", NA, 37),
`MV [l/min]` = c(5.0, NA, "+++", 4.8)
)
r <- data.table(
DateTime = lubridate::ymd_hm(
Expand Down

0 comments on commit c73a3dd

Please sign in to comment.