Thanks for all the help guys. This worked for me:
all6 <- arrange(all6, tdate,event_tim) lt <- ddply(all6,.(tdate),tail,1) lt$last_trans <-'Y' all6 <-merge(all6,lt, by.x=c("tdate","event_tim"), by.y=c("tdate","event_tim"),all.x=TRUE) -- View this message in context: http://r.789695.n4.nabble.com/Creating-a-new-by-variable-in-a-dataframe-tp4646782p4646799.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.