On 8/3/2006 10:34 AM, <[EMAIL PROTECTED]> noted that, starting with R-2.3.0, sort() fails to preserve date classes:
> dates <- seq(Sys.Date(), len=5, by="1 day") > dates[order(dates)] > [1] "2006-08-03" "2006-08-04" "2006-08-05" "2006-08-06" "2006-08-07" > sort(dates) > [1] 13363 13364 13365 13366 13367 and Duncan Murdoch <[EMAIL PROTECTED]> replied: > The problem is that some classes assume a particular ordering for > values; sort can mess them up. If you know that's not the case, you > can protect the class yourself: > cl <- class(dates) > sorteddates <- sort(dates) > class(sorteddates) <- cl I have to agree with Stephen (and Alex Dannenberg in another post) that this change is unfortunate for date classes. How do you reproduce this old behavior (without assuming alphanumeric ordering): > x <- matrix(1:12, 4,3) > group <- Sys.Date() + c(0,1,0,1) > rowsum(x, group) [,1] [,2] [,3] 2006-08-17 4 12 20 2006-08-18 6 14 22 Under R-2.3.1, the result is now: [,1] [,2] [,3] 13377 4 12 20 13378 6 14 22 Blech! -- David Brahm ([EMAIL PROTECTED]) ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel