gpt4 book ai didi

r - zoo/xts 微秒读取问题

转载 作者:行者123 更新时间:2023-12-01 12:52:59 30 4
gpt4 key购买 nike

数据看起来像

           Time  Set1    Set2   
10:19:38.551629 16234 16236
10:19:41.408010 16234 16236
10:19:47.264204 16234 16236

我正在尝试将其加载到动物园中。

orig <- read.zoo("~/sample.txt",sep="",header=TRUE,index.column=1,format="%H:%M:%S.%6f")

Error in read.zoo("~/sample.txt", sep = "", header = TRUE, index.column = 1, :
index has 3 bad entries at data rows: 1 2 3 ...

我已经检查了所有相关帖子1. R issue with rounding milliseconds2. Milliseconds puzzle when calling strptime in R3. How to parse milliseconds in R?

然而这并没有帮助。任何建议

最佳答案

您希望索引是一个时间类,例如 POSIXctPOSIXlt。此外,您的 format 论点不太正确。试试这个

read.zoo("~/sample.txt", header = TRUE, format="%H:%M:%OS", FUN=as.POSIXct)

其中,对于提供的示例数据,给出

read.zoo(text="           Time  Set1    Set2   
10:19:38.551629 16234 16236
10:19:41.408010 16234 16236
10:19:47.264204 16234 16236 ", header = TRUE, format="%H:%M:%OS", FUN=as.POSIXct)
# Set1 Set2
#2012-06-21 10:19:38.551629 16234 16236
#2012-06-21 10:19:41.408010 16234 16236
#2012-06-21 10:19:47.264204 16234 16236

关于r - zoo/xts 微秒读取问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11136340/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com