This will make a list where each element of the list is an xts object that begins at 8:30 and ends at 13:30 on the following day.
D <- split(mts, "days")
mts.days <- lapply(seq_along(D) - 1, function(i) {
if (i > 0) rbind(D[[i]]["T08:30/T23:59:59"], D[[i + 1]]["T00:00:00/T13:30:00"])
})
Edit:
The above can be extended by adding names to the list:
names(mts.days) <- as.Date(sapply(D, function(x) as.Date(start(x))))
Then, you could refer to the data from 8:30 a.m. on 2012-01-30 until 1:30 p.m. on 2012-01-31 like this
mts.days[["2012-01-30"]]
Alternatively, if you're only going to be pulling out one "day," you could do something like this (that follows the same basic logic)
PullDay <- function(Date="2012-01-30", t0="08:30", t1="13:30", mts=mts) {
string1 <- paste(Date, " ", t0, "/", Date, " 23:59:59", sep="")
string2 <- paste(as.Date(Date) + 1, " 00:00:00/", as.Date(Date) + 1, " ", t1, sep="")
rbind(mts[string1], mts[string2])
}
Then, PullDay("2012-01-30")
will give you the subset of data from 2012-01-30 08:30/2012-01-31 13:30.
Edit2: That simplifies to
PullDay <- function(Date="2012-01-30", t0="08:30", t1="13:30", mts=mts) {
mts[paste(Date, " ", t0, "/", as.Date(Date) + 1, " ", t1, sep="")]
}
which leads me to believe that I may still not understand what you want...