Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201945

How do I get all the dates with a particular time from a zoo object?

$
0
0

Suppose I have a zoo object of date/times (POSIXct) as my index and values:

...                     val
2006-08-01 10:00:00      1
2006-08-01 10:10:00      2
2006-08-01 10:20:00      3
2006-08-01 10:30:00      4
...
2006-08-02 10:00:00      5
2006-08-02 10:10:00      6
2006-08-02 10:20:00      7
2006-08-02 10:30:00      8
...

This should be simple but I can't think of how to get a list of all dates/times where let's say the time is 10:10:00am ...


Sample zoo data object:

Lines <- "datetime val
2006-08-01T10:00    1
2006-08-01T10:10    2
2006-08-01T10:20    3
2006-08-01T10:30    4
2006-08-01T10:40    10
2006-08-02T10:10    5
2006-08-02T10:20    6
2006-08-02T10:30    7
2006-08-02T10:40    8"

library(zoo)
z <- read.zoo(text = Lines, tz = "", header = TRUE, format = "%Y-%m-%dT%H:%M")

NOTE: I would prefer a base-R/zoo implementation but other packages would be interesting to see


Viewing all articles
Browse latest Browse all 201945

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>