如何从向量中获取第一个日期?
我有一个 POSIXct 对象向量,我想确定列表中的第一个和最后一个日期/时间值。
POSIXct_vector <- read.csv(file="data", as.is=TRUE)
POSIXct_vector$DateTime <- as.POSIXct(POSIXct_vector)
#returns NA
min(POSIXct_vector$DateTime)
#returns NA
max(POSIXct_vector$DateTime)
I have a vector of POSIXct objects, I would like to determine the first and the last date/time value in the list.
POSIXct_vector <- read.csv(file="data", as.is=TRUE)
POSIXct_vector$DateTime <- as.POSIXct(POSIXct_vector)
#returns NA
min(POSIXct_vector$DateTime)
#returns NA
max(POSIXct_vector$DateTime)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑您需要将
na.rm=TRUE
参数添加到您的命令中。这也意味着向量的至少一个元素尚未解析为有效时间。您还可以使用range
在一个命令中给出限制。I suspect you need to add the
na.rm=TRUE
argument to your commands. This also means that at least one of the elements of your vector hasn't been resolved to a valid time. You can also userange
to give the limits in one command.