[R] max and min with the indexes in a zoo object (or anything else that could solve the problem)

stephen sefick ssefick at gmail.com
Thu Aug 21 23:48:30 CEST 2008


library(zoo)
library(chron)
t1 <- chron("1/1/2006", "00:00:00")
t2 <- chron("1/31/2006", "23:45:00")
deltat <- times("00:15:00")
tt <- seq(t1, t2, by = times("00:15:00"))
d <- sample(33:700, 2976, replace=TRUE)
sin.zoo <- zoo(d,tt)

#there are ninety six reading in a day
d.max <- rollapply(sin.zoo, width=96, FUN=max)
d.min <- rollapply(sin.zoo, width=96, FUN=max)

this is about what I would like to do.  I want to be able to get the
max for one day and then also get the index that coincides with this
max time period.  Also, the same thing with the min.  With the real
data I am trying to find out at what time the maximum dissolved oxygen
value is for each day.

Thanks

-- 
Stephen Sefick
Research Scientist
Southeastern Natural Sciences Academy

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

	-K. Mullis



More information about the R-help mailing list