我有一个数据框,看起来像这样:
tbl <- data.frame(ISO_Timestamp = c(1612972204,1612972214,1612972224,1612972234),S1 = c(7056,7101.1,5145,2198))
我希望将ISO_timestamp列转换为日期-时间POSIXt格式。我可以像这样转换单个ISO_Timestamp时间戳对象:
lubridate::as_datetime(1612988995)
[1] "2021-02-10 20:29:55 UTC"我尝试这样转换整个列,但它不起作用。
data_1 <- tbl %>%
mutate(date_time = as_datetime(`ISO_Timestamp`))我收到以下错误:
Warning messages:
1: Problem with `mutate()` input `date_time`.
x All formats failed to parse. No formats found.
ℹ Input `date_time` is `as_datetime(`ISO_Timestamp`)`.
2: All formats failed to parse. No formats found. 我做错了什么?
发布于 2021-02-19 01:08:28
列名没有任何空格
library(lubridate)
library(dplyr)
tbl %>%
mutate(date_time = as_datetime(ISO_Timestamp))-output
# ISO_Timestamp S1 date_time
#1 1612972204 7056.0 2021-02-10 15:50:04
#2 1612972214 7101.1 2021-02-10 15:50:14
#3 1612972224 5145.0 2021-02-10 15:50:24
#4 1612972234 2198.0 2021-02-10 15:50:34https://stackoverflow.com/questions/66264693
复制相似问题