如何找到两个时间向量的不同元素? [英] How to find different elements of two time vectors?
本文介绍了如何找到两个时间向量的不同元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑这两个时间向量:
a<-seq(as.POSIXct("2010-01-01 05:00:00"), as.POSIXct("2010-01-02 23:55:00"), by = '5 min')
b<-seq(as.POSIXct("2010-01-01 00:00:00"), as.POSIXct("2010-01-03 23:55:00"), by = '10 min')
如何获得这两个向量之间的不同元素?我试过了:
How to get the different elements between these two vectors? I've tried:
union(setdiff(a, b), setdiff(b, a))
但是返回的值不是时间格式。
But the returned values are not in time format.
推荐答案
这仅使用保留 POSIXct
类的操作:
This uses only operations that preserve "POSIXct"
class:
c(a[!a %in% b], b[!b %in% a])
这篇关于如何找到两个时间向量的不同元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文