Skip to content
Prev 318226 / 398503 Next

Selecting First Incidence from Longitudinal Data

I think we need a task view on longitudinal data manipulation.  There are so
many approaches to this - people need help navigating them.

I tend to stay away from the lapply-split methods as they don't look quite
as clean and may take longer to run.  The aggregate function uses too much
data frame subscripting.  The plyr package and the mApply function in the
Hmisc package provide some other nice solutions.  Often I like to stick with
tapply using constructs like 

with(mydata, tapply(1:nrow(mydata), subjectID, function(i) {... operate on
variables in mydata subscripted by [i] ...)))

Frank


arun kirshna wrote

            
head(x[x$COMPL!=0,],1) else head(x,1)))

            
patients for which no complication occurred. That is, for my data I want to
include patient no. 4, for which the COMPL value will be 0.
by=list(dat0$ID),FUN=length)$x, FUN=function(x){seq(1, x)})))
by=list(dat1$ID),FUN=length)$x, FUN=function(x){seq(1, x)})))
COMPL!=0

            

            

            
http://www.R-project.org/posting-guide.html

            
-----
Frank Harrell
Department of Biostatistics, Vanderbilt University
--
View this message in context: http://r.789695.n4.nabble.com/Selecting-First-Incidence-from-Longitudinal-Data-tp4659455p4659530.html
Sent from the R help mailing list archive at Nabble.com.