Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在这里阅读了几篇关于如何在指定时间间隔内选择最后一个数据点的文章。
我的数据是 1 分钟的城市湿度读数。数据从 mySQL 中提取并保存在没有时间对象的 zoo 对象中。所以 R 无法知道时间间隔。但是鉴于我知道数据是 1 分钟的数据,我可以以任何方式聚合数据以每 5 分钟、10 分钟、15 分钟等选择最后一个数据点。
我一直在阅读 ?aggregate 和 ?trunc 但我认为我的情况有点不同,因为我没有与湿度数据相关的日期/时间间隔列。
任何帮助将不胜感激。
就像你会用任何向量一样:
> Test <- as.zoo(1:33) > Test[seq(5,length(Test),by=5)] 5 10 15 20 25 30 5 10 15 20 25 30