Skip to content
Prev 175483 / 398506 Next

Calculating First Occurance by a factor

I discovered Hadley Wickham's "plyr" package last week and have found
it very useful in circumstances like this:

library(plyr)

firstfixtime = ddply(
       .data = data
       , .variables = c('Sub','Tr','IA')
       , .fun <- function(df){
               df$FixTime[which.min(df$FixInx)]
       }
)