Re: [R] create a index.date column

2011-07-28 Thread jose Bartolomei
Dear Dennis, I appreciate your time. I studied and implemented your recommendation and is exactly what I needed. I was in an unproductive loop in this. Thank you very much, Jose > Date: Wed, 27 Jul 2011 14:28:51 -0700 > Subject: Re: [R] create a index.date column > From: djmu...@

Re: [R] create a index.date column

2011-07-27 Thread Dennis Murphy
Hi: I prefer to use one of the summarization packages for this sort of thing, but aggregate() works, too. Here are two versions of the same idea: # Uses ddply() in the plyr package: index.date <- function(d) { require('plyr') out1 <- ddply(d, .(id, rcat), summarise, index = max(tdiff))

[R] create a index.date column

2011-07-27 Thread jose Bartolomei
Dear R users, I created a matrix that tells me the first day of use of a category by id. #Calculate time difference test$tdiff<-as.numeric(difftime(as.Date("2002-09-01"), test$ftime, units = "days")) # obtain the index date per person and dcategory