2

I've been trying to find forums to answer this question, but I'm afraid I didn't find how to solve this ..

I have data with this format:

2013-12-17 22:45:00 18.521
2013-12-17 23:00:00 17.760
2013-12-17 23:15:00 18.140
2013-12-17 23:30:00 18.806
2013-12-17 23:45:00 18.045
2013-12-18 02:00:00 16.427
2013-12-18 02:15:00 16.237
2013-12-18 04:15:00 11.236
2013-12-18 04:30:00 11.041
2013-12-18 04:45:00 11.041
2013-12-18 05:00:00 10.846
2013-12-18 05:15:00 10.455
2013-12-18 05:30:00 10.553
2013-12-18 05:45:00 10.063
2013-12-18 06:00:00 10.259
2013-12-18 06:15:00 10.161
2013-12-18 06:30:00 10.063
2013-12-18 06:45:00  9.866
2013-12-18 07:00:00  9.866
2013-12-18 07:15:00  9.965
2013-12-18 07:30:00 10.651
2013-12-18 07:45:00 10.944
2013-12-18 08:00:00 11.431

The periodicity is 15 minutes each day, for several months. And it is already stored in a var with class: xts, zoo

When I use:

period.apply(
  xts.ts,
  endpoints(xts.ts, on = "days", 1),
  function(x) apply(x, 2, min)
)

I obtained something like this:

[,1]
2013-12-11 23:45:00 10.455
2013-12-12 23:45:00  8.879
2013-12-13 23:45:00 12.980
2013-12-14 23:45:00 12.883
2013-12-15 23:45:00 12.497
2013-12-16 23:45:00 10.944
2013-12-17 23:45:00 11.041
2013-12-18 08:00:00  9.866

However, I would like to know the exact time for the min value (or values) & for each day, It always appears 23:45:00 (except in the last case: 08:00:00), which is not correct, as you can see in the original data:

2013-12-18 06:45:00  9.866
2013-12-18 07:00:00  9.866

Moreover, I try to use:

separated_by_days <- split(xts.ts, f = "days", drop=FALSE, k = 1)

And I get a list with the info separated by days, but if I use

period.apply(
  separated_by_days[[1]],
  INDEX=endpoints(days[[1]], on="days"),
  FUN=min
)

The result is the same. :(

I would appreciate if you give me some clue for solving this.. Thank you!

thelatemail
  • 91,185
  • 12
  • 128
  • 188

0 Answers0