Skip to content
Prev 326744 / 398502 Next

calculate time from dates

Hello,

It's better if you keep it on the list, the odds of getting more and 
better answers is greater.

As for your question, I've made up a dat2 with an extra column. Try the 
following, it's independent of the number of columns.



dat2 <- data.frame(ID = dat1$ID,
	month = mondf("01/01/2008", dat1$date, format = "%m/%d/%Y") + 1,
	other = rnorm(6))

dat2

sp <- split(dat2, list(dat2$ID, dat2$month))
result <- do.call(rbind, lapply(sp, tail, 1))
rownames(result) <- seq_len(nrow(result))
result


Hope this helps,

Rui Barradas


Em 12-07-2013 09:04, Gallon Li escreveu: