Fwd: Matching when each subject has multiple records

Naresh Gurbuxani <[email protected]>
Newsgroups gmane.comp.lang.r.general
Message-ID <DM3PPF9A5B544E04D59B8E184B3CDF5A0F3FA16A@DM3PPF9A5B544E0.NAMP223.PROD.OUTLOOK.COM>


> 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]]

______________________________________________
[email protected] 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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.