数字到时间的转换在 r 中停止工作

Numeric conversion to time has stop working in r

我在 r 中遇到了数字和时间转换的新问题。在过去的两个月里,我一直在 R 中解析这些变量,从数字到时间。今天,我收到警告消息:“某些字符串无法解析”。我一直在使用 lubridate 库,它毫不费力。难不成是 R Studio 闹了一天?

数据框;

Rows: 413
Columns: 4
$ Id          double 1503960366, 1503960366, 1503960366, 1503…
$ date        chr "4/12/2016 12:00:00 AM", "4/13/2016 12:0…
$ time.asleep double 327, 384, 412, 340, 700, 304, 360, 325, …
$ time.in.bed double 346, 407, 442, 367, 712, 320, 377, 364, …

您确定您使用的是 lubridate::hms 而不是 hms::hms 吗?

lubridate::hms(327)

[1] NA

Warning message: In .parse_hms(..., order = "HMS", quiet = quiet) : Some strings failed to parse, or all strings are NAs

hms::hms(327)
#00:05:27

或整列。

sleep.day$time.asleep <- hms::hms(sleep.day$time.asleep)