Skip to content
Prev 155352 / 398513 Next

How to preserve date format while aggregating

As requested in the last line to every message to r-help a cutdown
version of the data should be posted with the question.

Suppose such a cut down version is this:

DF <- data.frame(Date = ISOdatetime(2008, 1, c(1, 2, 5, 3, 4), 0, 0, 0),
	Subject = c(1, 1, 2, 2, 2))

# Then sort the data and take first one in each group:

DFsort <- DF[order(DF$Subject, DF$Date), ]
DFsort[!duplicated(DFsort$Subject), ]

If its already sorted then omit first line and use DF in place
of DFsort in second line.

On Mon, Sep 8, 2008 at 9:15 AM, Erich Studerus
<erich.studerus at bli.uzh.ch> wrote: