매일 밤 도는 감사 스크립트(Rscript, base R)가 최고 온도가 기준을 넘는 냉동고를 표시해 줘요. 어젯밤 U-03의 로거가 뽑혀 있어서, export에서 그 장비의 temp_c가 전부 문자열 ERR이에요. 그런데도 리포트에는 U-03이 ok라고 나와요. 아무한테도 알림이 안 갔고요. 출력된 표를 보면 그 장비는 n_valid가 0, peak_c가 -Inf, mean_c가 NaN이에요. 다른 장비들은 맞게 나오는 것 같아요.
읽는 단계가 문제라고 생각했어요. na.strings에 "ERR"를 추가했고, temp_c가 숫자로 들어오는지 확인했고, --verbose로도 돌려 봤어요. 행 개수는 맞아요. 달라진 건 없었어요.
관련 부분이에요:
readings <- read.csv(infile, stringsAsFactors = FALSE,
na.strings = c("", "NA", "ERR"))
peak_c = max(df$temp_c, na.rm = TRUE),
mean_c = round(mean(df$temp_c, na.rm = TRUE), 1)
...
res$status <- ifelse(res$peak_c > LIMIT_C, "ALARM", "ok")
LIMIT_C는 -65예요. 실행이 끝날 때쯤 R이 경고도 하나 출력해요. 제 터미널은 시작할 때마다 LC_CTYPE 경고가 떠서 경고는 읽지 않게 됐어요. 예전에 제 작업 하나가 그런 경고를 둔 채로 한 달 동안 돌았던 적도 있고요.
읽는 단계 문제인가요, 아니면 그 이후 단계 문제인가요?
영어에서 번역·원문 보기My nightly audit script (Rscript, base R) flags freezers whose peak temp is above a limit. Last night U-03's logger was unplugged, so every temp_c for it in the export is the string ERR. The report still says U-03 is ok. Nobody got paged. The printed table shows n_valid 0, peak_c -Inf and mean_c NaN for that unit. The other units look right.
I assumed the reading step was broken. I added "ERR" to na.strings, checked that temp_c comes in numeric, and ran with --verbose. The row count is correct. Nothing changed.
The relevant part:
readings <- read.csv(infile, stringsAsFactors = FALSE,
na.strings = c("", "NA", "ERR"))
peak_c = max(df$temp_c, na.rm = TRUE),
mean_c = round(mean(df$temp_c, na.rm = TRUE), 1)
...
res$status <- ifelse(res$peak_c > LIMIT_C, "ALARM", "ok")
LIMIT_C is -65. R also prints a warning near the end of the run. My terminal already complains about LC_CTYPE on every start, so I stopped reading warnings. Once, a job of mine ran for a month on a warning like that.
Is this the reading step or something after it?