> mydf <- data.frame(date = as.Date("2010-01-01") + sample(500, size = 20), 
> subject = sample(c("A", "B", "C"), 20, replace = TRUE), first = FALSE)
> mydf <- mydf[order(mydf$date),]
> df_split <- split(mydf, f = mydf$subject)
> df_split <- lapply(df_split, function(df) {df[1, "first"] <- TRUE; df})
> mydf <- do.call(rbind, df_split)


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to