hms功能踢出NAs [关闭]

问题描述 投票:-1回答:1

继续收到此警告消息:

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

该函数将我的角色向量中的所有数据替换为NA

我试过通过hms()包运行lubridate函数并再次尝试使用POSIXct

combined$start<- c("8:45" "12:10" "16:00")

combined$start <- as.character(combined$start)

combined$start <- hms(combined$start)

我想将combined$start中的字符转换为hms,但是当我尝试运行最后一行代码时,我只得到NA

r type-conversion lubridate posixct
1个回答
1
投票

你在combined$start没有任何秒数,所以试试用hm。

combined$start <- hm(combined$start)

我还注意到在创建combined$start时没有逗号,所以请尝试将行更改为:

combined$start<- c("8:45", "12:10", "16:00")
© www.soinside.com 2019 - 2024. All rights reserved.