Skip to content

Commit c0ae0d5

Browse files
committed
refining import function
1 parent 288fb6e commit c0ae0d5

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

R/import_expressions.R

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,24 @@ import_expr <- list(
548548
)
549549
data <- data |>
550550
dplyr::rename(Datetime = Date) |>
551-
dplyr::mutate(Datetime = lubridate::force_tz(Datetime, tz = tz))
551+
dplyr::mutate(Datetime = lubridate::force_tz(Datetime, tz = tz),
552+
dplyr::across(c(Lux, Dis),
553+
\(x) {
554+
dplyr::case_when(
555+
x == -1 ~ "sleep_mode",
556+
x == 204 ~ "out_of_range"
557+
)
558+
}, .names = "{.col}_status"),
559+
Lux = dplyr::case_when(
560+
Lux == -1 ~ NA,
561+
.default = Lux
562+
),
563+
Dis = dplyr::case_when(
564+
Dis == -1 ~ NA,
565+
Dis == 204 ~ NA,
566+
.default = Lux
567+
),
568+
)
552569
})
553570
)
554571

0 commit comments

Comments
 (0)