Trying to use dates in their R-native form (e.g., POSIXct) rather than
turning them into character strings, I've encountered the following problem.
I create a data frame where one column is dates. Then I use "by()" to do a
calculation on grouped subsets of the data. When I try to extract values
from the result, I get "subscript out of bounds". The example below shows
the error.

> x <- data.frame(A= c("X", "Y", "X", "X", "Y", "Y", "Z" ), D =
as.POSIXct(c("2008-11-03","2008-11-03","2008-11-03", "2008-11-04",
"2009-01-13", "2009-01-13", "2009-01-13")), Z = 1:7)
> m <- by(x, list(A=x$A, D=x$D), function(v) { sum(v$Z); })
> m[x$A[1], x$D[1]]
Error: subscript out of bounds


Rgds,
Oren Cheyette

	[[alternative HTML version deleted]]


